I have a property. In my unit-test I want to make sure that set is not called. How I can achieve this?
I have able to check that value is set, but how can I make sure that it is not set.
public ISomeInterface
{
bool? SomeProperty { get; set; }
}
public SomeClass
{
SomeClass(ISomeInterface someInterface)
{ _someInterface = someInterface; }
public void SomeMethod(bool condition)
{
if (condition)
_someInterface.SomeProperty = true;
}
}
// Test
var moq = new Mock<ISomeInterface>();
var target = new SomeClass(moq.Object);
target.SomeMethod(false);
// Check here that someInterface.SomeProperty set is not called.
moq.VerifySet(i => i.SomePropery = true); // This checks that set is called. But how to check if it is not called?