I am trying to create a plugin for cheching use of NMock in my unit tests. It is possible to set up NMock expectations, for example
Mockery mocks = new Mockery();
myMockObject mockCurrencyService = mocks.NewMock]]>();
but then forget to check the expectations afterward, ie the line
is missing. I would like my plugin to generate a warning on the Expect line if there is no corresponding VerifyAllExpectationsHaveBeenMet call.
So far I have a plugin that can locate the 'Expect' IReferenceExpressions. I am not sure what to do next. I had assumed something like:
For each Expect call,
find out which mock object it is operating on (i.e. the argument to the 'On()' part)
find out which Mockery that object was created from
look for a call to VerifyAllExpectationsHaveBeenMet on that mockery which is guaranteed to be executed after the Expect call, and generate a warning if there is no such call.
Is this the right approach? If so, please can you provide help/examples for these steps?