We started out with a fairly basic exploration, looking at how Substitute.For
would also validate when expressed like:
After the break we decided to look at how NSubstitute deals with raising events. To do this we built a Car class to take an IEngine (part of the tests in NSubstitute) and wrote a test, as you might in the 'real world' which raised the IEngine Stopped event. We used NSubstitute to create a fake of IEngine and injected it into Car and then raised the Stopped event using:
_engine.Stopped += Raise.Event(...);
From there we dug (pun absolutely intended) into the call stack to work out how event raising was implemented.
In conclusion the choice of NSubstitute was both good and bad. On the good side was the opportunity to look through some beautiful and clean code. The flip side was that the structure of the code, Overenthusiastic OO, as Dave Tchepak calls it, was probably a bit much to tackle at the same time. It would have also been really good to have had a more detailed look at the structure of the unit tests, but in the end there just wasn't time to look at it all. Maybe another time...