Skip to content

Commit

Permalink
SetupProperty fails for partially overridden property
Browse files Browse the repository at this point in the history
because it tries to "upgrade" the property in the LINQ expression to
the most derived one. The upgrade process verifies its own correctness
by comparing getters, however a getter may be absent in a property of
a "derived" class.
  • Loading branch information
stakx committed Oct 19, 2019
1 parent a854f34 commit 64da4d5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/Moq.Tests/StubExtensionsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ public void SetupAllProperties_retains_value_of_derived_read_write_property_that
Assert.Equal("value", mock.Object.Property);
}

[Fact]
public void SetupProperty_retains_value_of_derived_read_write_property_that_overrides_only_setter()
{
var mock = new Mock<OverridesOnlySetter>();
mock.SetupProperty(m => m.Property);
mock.Object.Property = "value";
Assert.Equal("value", mock.Object.Property);
}

private object GetValue() { return new object(); }

public interface IFoo
Expand Down

0 comments on commit 64da4d5

Please sign in to comment.