Advanced Unit Testing
As we’ve seen, testing is incredible and can give you the freedom to effectively refactor your code in relative safety. Sometimes, code is written in a way that makes testing difficult and you need a few more tools. In this chapter, we’ll explore a handful of popular .NET libraries that can improve the readability of your tests and give you more options for testing code – including those tricky classes with complex data or dependencies.
We’ll cover the following topics in this chapter:
- Creating readable tests with Shouldly
- Generating test data with Bogus
- Mocking dependencies with Moq and NSubstitute
- Pinning tests with Snapper
- Experimenting with Scientist .NET