This is a quick and dirty introduction into unit testing. The aim is to show the evolution of code from not unit testable to unit testable. I'll also introduce mocking with Moq and a nicer way to do your asserts with Fluent Assertions.
This is by no means an exhaustive or comprehensive workshop. The aim is to give a gentle introduction and provide a platform for experimentation and learning.
This repo has a number of branches which will be worked through in turn.
This branch introduces the library that we want to test. The code isn't unit testable at this stage
In this branch we transform the code into a state which can be unit tested
There are three step three branches (step-three, step-three-b and step-three-c). This step covers initial setup, writing a failing test and then writing the code needed to make the test pass
In the step four branches (step-four and step-four-b) Moq and Fluent Assertions are introduced.
There is no step five branch - clone the repo and use it as a playground!