Hi
Sorry I still don't understand what you really want to do when the
property is set. I'll try to explain what are the options:
When you set a property you are really dealing with void method that gets
one argument
So
class MyClass
{
private int x;
public int Prop
{
set { x = var; }
}
}
is like
class MyClass
{
private int x;
public void Prop(int n)
{
x = n;
}
}
What you can do here is few things:
:arrow: Ignore the implementation
mock.ExpectSet("Prop");
:arrow: Check the arguments
mock.ExpectSet("Prop").Args(1);
This will check that that the property is set to 1. Any other number will
cause TypeMock to throw an exception.
:arrow: Do a custom arguments check with your own custom checker.
This is useful if you want to check for example that the arguments are in specific range.
mock.ExpectSet("Prop").Args(new ParameterCheckerEx(MyCostumCheckerMethod));
:arrow: All of the above plus verify that the method was called
MockManager.Verify();
If you want the property to be set to a specific value you should mock
the method that set the property
mock.ExpectAndReturn("MyMockedMethod", 5);
// ...
myClass.Prop = MyMockedMethod();
Hope it helps please tell if there is still something unclear regarding this issue.