In Visual Studio it is really simple to add unit tests that are automatically run in your build script. Right click your solution to add a test project:
Add a few test methods:
Check this Step-By-Step for an explanation:
Check this link for some Unit test basics:
https://docs.microsoft.com/en-us/visualstudio/test/unit-test-basics?view=vs-2017
/// <summary>
/// Test if flipcoins throws as many times as requested
/// </summary>
[TestMethod()] public void FlipCoinsTest1Times()
{
//Arrange
int odd, even;
int times = 1;
//Act
CoinFlipper coinFlipper = new CoinFlipper();
coinFlipper.FlipCoins(times, out odd, out even);
//Assert Assert.IsTrue(times == odd + even);
}
Open Test explorer window
Right click a selection of tests and select “Run selected tests”.
When the tests are OK, we can check in the solution. Default the Build in Azure will run libraries with names containing *test*.
The results for this solution: 8 tests passed.