August 2018
Intermediate to advanced
794 pages
28h 4m
English
For simple calculations, some programmers prefer to write less test code by putting the values directly into the assertion. So, as shown below, 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 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 preparation, code execution, and storage of results, and the assertion of properties about those results, are structured clearly in a sequence of Arrange/Act/Assert ...
Read now
Unlock full access