I ran into a problem the other day where I was doing some cost calculations and wasn’t getting the expected result, the problem turned out to be I was doing the calculations before everything got loaded, simple mistake.
Thought it would be interesting to show the solution I used for testing, lets say we have a simple method for updating an employee record.
fairly simple, you call AuthRequests to see if the user and update the employee and then you update the employee. Here is an example test class for it
the only problem is the tests still pass if the method looks like this
so lets add some sequence tests, basically we add a counter and a dictionary<string,int> to record what was executed and it what order using the Moq callback.
for the full source see the sample application here.