Summary
In this chapter, we reviewed the critical importance of writing unit tests and comprehensively testing your program. In a nutshell, unit tests allow you to code with confidence, knowing that if you make a change and it breaks something seemingly unrelated, you’ll find out about it immediately.
We saw that, at times, your unit test must interact with slower external systems (APIs, databases, and more) and that you can keep your subsecond response time by using mocks; the mocking library we chose is NSubstitute
, though there are other free mocking systems as well (a very popular one is Moq).
In order to facilitate using mocks, we looked at dependency injection and briefly reviewed the role of IoC containers. In the next chapter, Consuming a Rest Service, we will look at getting our data from a cloud-based (Azure) service, rather than mocking the data.