I am experiencing difficulty mocking an interface that has write only properties. When I try to set the property's value a NullReferenceExcpetion is thrown.
Here is some sample code (which throws the exception):
By simply adding a getter to the interface, the test passes as expected:
I would like to be able to mock interfaces that might have write only properties.
Thanks
Here is some sample code (which throws the exception):
public interface IFoo{ int Foo { set; }}[TestMethod]public void TestSetOnlyProperty(){ IFoo fooMock = Mock.Create<IFoo>(); fooMock.Foo = 30; Mock.AssertSet(() => fooMock.Foo = 30);}By simply adding a getter to the interface, the test passes as expected:
public interface IFooGetAndSet{ int Foo { get; set; }}[TestMethod]public void TestSetProperty(){ IFooGetAndSet fooMock = Mock.Create<IFooGetAndSet>(); fooMock.Foo = 30; Mock.AssertSet(() => fooMock.Foo = 30);}I would like to be able to mock interfaces that might have write only properties.
Thanks