:arrow: This feature is already implemented in Typemock - although it is written in the last sentences on the
Mocking Interfaces Chapter (and
here) and should be more visible.
All abstract methods and properties are created with a default implementation. By default, these methods are strict and will fail if they are called without any expectations. To use these you must change the strictness (see Arbitrary Calls).
Here is the default implementation:
* All void calls return
* Other methods will return a default value (0 or null depending on the return type)
* Properties will behave like simple properties
All you have to do is:
mock.Strict = false; // all properties work...
So here is how you do it:
[Test,VerifyMocks]
public void PropertyBehaviorForAllProperties()
{
MockObject<IDemo> mock = MockManager.MockObject<IDemo>();
mock.Strict = false; // all properties work...
IDemo demo = mock.Object; // this is our mocked instance
for (int i = 0; i < 49; i++)
{
demo.Prop = "typemock" + i;
Assert.AreEqual("typemock" + i, demo.Prop);
}
}
To use allow a specific property (public or private) use:
mock.MethodSettings("Prop").IsStrict = false;
:idea: As you said there is no need to do this for concrete classes/methods.