Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #328 #9

Merged
merged 1 commit into from
Jun 18, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Source/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ public static bool CanOverrideGet(this PropertyInfo property)
{
if (property.CanRead)
{
var getter = property.GetGetMethod();
return getter != null && getter.IsVirtual && !getter.IsFinal;
var getter = property.GetGetMethod(true);
return getter != null && getter.CanOverride();
}

return false;
Expand All @@ -197,8 +197,8 @@ public static bool CanOverrideSet(this PropertyInfo property)
{
if (property.CanWrite)
{
var setter = property.GetSetMethod();
return setter != null && setter.IsVirtual && !setter.IsFinal;
var setter = property.GetSetMethod(true);
return setter != null && setter.CanOverride();
}

return false;
Expand Down
18 changes: 18 additions & 0 deletions UnitTests/Linq/QueryableMocksFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@ public void ShouldSupportSettingDtoPropertyValue()
Assert.Equal("foo", target.Value);
}

[Fact]
public void ShouldSupportSettingDtoProtectedPropertyValue()
{
var target = Mock.Of<Dto>(x => x.ProtectedValue == "foo");

Assert.Equal("foo", target.ProtectedValue);
}

[Fact]
public void ShouldSupportSettingDtoProtectedVirtualPropertyValue()
{
var target = Mock.Of<Dto>(x => x.ProtectedVirtualValue == "foo");

Assert.Equal("foo", target.ProtectedVirtualValue);
}

[Fact]
public void ShouldOneOfCreateNewMock()
{
Expand Down Expand Up @@ -172,6 +188,8 @@ public void Do()
public class Dto
{
public string Value { get; set; }
public string ProtectedValue { get; protected set; }
public virtual string ProtectedVirtualValue { get; protected set; }
}

public interface IFoo
Expand Down