Skip to content

Commit a0243cd

Browse files
committed
Property setups are ignored on mocks instantiated using Mock.Of
1 parent 611652c commit a0243cd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/Moq.Tests/Regressions/IssueReportsFixture.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,6 +3549,36 @@ public interface IMockObject
35493549

35503550
#endregion
35513551

3552+
#region 1066
3553+
3554+
public class Issue1066
3555+
{
3556+
public interface IX
3557+
{
3558+
int Property { get; set; }
3559+
}
3560+
3561+
[Fact]
3562+
public void Stubbed_property_set_before_SetupGet()
3563+
{
3564+
var mock = Mock.Get(Mock.Of<IX>());
3565+
mock.Object.Property = 4;
3566+
mock.SetupGet(m => m.Property).Returns(3);
3567+
Assert.Equal(3, mock.Object.Property);
3568+
}
3569+
3570+
[Fact]
3571+
public void Stubbed_property_set_after_SetupGet()
3572+
{
3573+
var mock = Mock.Get(Mock.Of<IX>());
3574+
mock.SetupGet(m => m.Property).Returns(3);
3575+
mock.Object.Property = 4;
3576+
Assert.Equal(3, mock.Object.Property);
3577+
}
3578+
}
3579+
3580+
#endregion
3581+
35523582
#region 1071
35533583

35543584
public class Issue1071

0 commit comments

Comments
 (0)