If you are unit testing a method that gets an Arranged mocked property and, then, sets that property, how do you verify the results at then end?
For example, let's say we want to unit test a method that looks like:
public void MyMethod()
{
if (_view.SelectedObject != null)
_view.SelectedObject = null;
}
I would expect to be able to write a test similar to:
[TestMethod]
public void MyMethodTest()
{
var view = Mock.Create<
iView
>();
var testObject = new Thingy();
Mock.Arrange(() => view.SelectedObject).Returns(testObject);
Mock.ArrangeSet(() => view.SelectedObject = null);
objectUnderTest.MyMethod();
Assert.IsNull(view.SelectedObject);
}
The assert fails because the mocked property return is still in effect and you get testObject. What's the proper way to write this test? Thanks!