How can I verify that a property's set() was called?

0 votes
How can I verify that a property's set() was called with exact argument? (when set is public or private)
asked Jul 23, 2012 by Noob (180 points)

1 Answer

+1 vote
Public set:

[TestMethod]
[Isolated]
public void TestPropertySET()
{
    Boo b = Isolate.Fake.Instance<Boo>();
    b.Property = 1;
    Isolate.Verify.WasCalledWithExactArguments(() => { b.Property=1; });
}


Private set:

[TestMethod]
[Isolated]
public void TestPrivatePropertySET()
{
   Boo b = Isolate.Fake.Instance<Boo>();
   b.setPrivateProperty(1);
   Isolate.Verify.NonPublic.Property.WasCalledSet(b, "Property").WithArgument(1);
}
answered Jul 23, 2012 by NofarC (3,980 points)
...