Unit Tests - smudge202/clean-living GitHub Wiki

Usage

Unit tests are used to automate tests of functionality of code, normally a specific behaviour of a method. Commonly a unit test is broken into three parts: arrange, act, assert. The arrange is used to setup anything needed for the tests, the act is the method or action you are wanting to test, the assert is the check to make sure the code behaved as expected.

Whenever making changes to the code base all unit tests should be re-run to ensure no bugs have been introduced.

Frameworks

Example

[Fact]
public void ShouldReturnTrue()
{
  //Arrange
  var x = 1;
  var y = 1;

  //Act
  var result = x==y;

  //Assert
  Assert.IsTrue(actual);
} 

References