chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
How can I verify that a property's set() was called with exact argument? (when set is public or private)
asked by Noob (2.1k 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 by NofarC (4k points)
...