Tag Archives: NMock

Loose expectations with NMock2

NMock2 will have a verification failure if all expected calls are not made and if any unexpected calls are made. That last bit can make writing test code rather tedious.
I have a presenter and I’m testing its normal path using a bunch of calls like the following:

Expect.Once.On(view).GetProperty(”Name”).Will(Return.Value(”Widget”));
Expect.Once.On(view).GetProperty(”Quantity”).Will(Return.Value(3));
Expect.Once.On(view).GetProperty(”Price”).Will(Return.Value(9.95m));
Expect.Once.On(view).Method(”ShowTotal”).With(29.85m);

That’s all good, but now I want to test [...]

Leave a comment