Hi,
Here's your test:
[Test]
[VerifyMocks]
public void TestExpectSet2()
{
SizeDT size = SizeDT.Empty;
Mock mock = MockManager.Mock(typeof(SizeDT));
mock.ExpectSet("X");
size.ArgumentTest();
}
Notice that you call MockManager.Mock
after you create "size" the instance you later call the function on.
Here's what happens: Mock means the next time you see a "new" it will be mocked. The next time a "new" is seen is inside ArgumentTest:
public void ArgumentTest()
{
x = 10;
y =10;
SizeDT size = new SizeDT(x,y);
size.GreatStuff(100);
X = size.x;
X = -40;
Y = size.y;
}
Note that this is a local "size". So this one is mocked, but the external "size" is not. Now, in the lines:
X = size.x;
X = -40;
Y = size.y;
The GET properties of the local (and mocked) "size" are called, and they are set into the external (and not mocked) "size". . However, since we didn't satisfy the expectation we set on the external "size", but on the local "size", and we didn't set anything on the local size.x, you get the verification exception.
So what you need to do is call Set on the instance you plan to mock.
Let me know if I can help further.