For simple calculations, some programmers prefer to write less test code by putting the values directly into the assertion. So, as shown here, our 1 + 1 = 2 test could be expressed in a single assertion, where the expected value of 2 and the expression 1 + 1 are entered directly into an AreEqual(...) method's invocation:
using NUnit.Framework;
class SimpleTester
{
[Test]
public void TestOnePlusOneEqualsTwo()
{
// Assert
Assert.AreEqual(2, 1 + 1);
}
}
However, if you are new to testing, you may prefer the previous approach, whereby the way you prepare, execute, and store the results, as well as the property assertions about those results, are structured clearly in a sequence of Arrange/Act/Assert. By storing values in meaningfully named variables, what we are asserting is very clear.