Testing the functions
In the following sections, we will cover the functions testing. We will focus, primarily, on Unit and Integration testing. These tests can be run locally on the development machine, or run automatically by continuous integration tools.
Unit testing
When developing unit tests, C# developers, typically, leverage one of the unit testing frameworks, such as NUnit, XUnit, or MSTest. Testing frameworks make it easy to perform common tasks such as creating new tests, running groups of tests, and reviewing the test run summary.
This book will leverage MSTest, which is fully integrated with Visual Studio.
Unit testing approach
A common approach to writing tests can be called AAA, which stands for Arrange -> Act -> Assert. With this approach, each test case is structured as follows:
- Arrange: This section of the test initializes the objects, variables, and mocks, and sets the data passed to the unit under test
- Act: This section invokes the unit under test with the arranged parameters...