Arrange, Act, Assert
Arrange, Act, Assert (AAA or 3A) is a well-known method for writing readable tests. This technique allows you to clearly define your setup (arrange), the operation under test (act), and your assertions (assert). One efficient way to use this technique is to start by writing the 3A as comments in your test case and then write the test code in between. Here is an example:
[Fact]
public void Should_be_equals()
{
// Arrange
var a = 1;
var b = 2;
var expectedResult = 3;
// Act
var result = a + b;
// Assert
Assert.Equal(expectedResult, result);
}
Of course, that test case cannot fail, but the three blocks are easily identifiable with the 3A comments.In general, you want the Act block of your unit tests to be a single line, making the test focus clear. If you need more than one line, the chances are that something is wrong in the test or the design.
When the tests are very small (only a few lines), removing the comments might help readability...