Moq examples, Part II 58
A few blog articles ago I showed some examples using Moq. I created those examples in anticipation of using Moq in a TDD class with a group in Canada.
What I ended up creating was different for a number of reasons. The final version is somewhat cleaned up compared to those first examples, so here are those examples as well: actual test class created.
These tests are not really that different from the first version, other than I did not use exceptions as much.
After the underlying LoginService was created with these tests, I had the students refactor to the GoF State Design Pattern. If you’re feeling like a little practice, consider:- Creating one test at a time
- Write the underlying service
- When all tests are passing, try to refactor to the state pattern.
It’s a good exercise. The guys in Canada seemed to really grok Moq and started using it to characterize their actual code the next day.
