August 2018
Intermediate to advanced
794 pages
28h 4m
English
When comparing values with assertions, it is customary for the expected (correct) value to be given first, followed by the actual value:
Assert.AreEqual( <expectedValue>, <actualValue> );
While it makes no difference to the true or false nature of equality, and so on, it can make a difference to messages when tests fail with some testing frameworks (for example, "got 2 but expected 3" has a very different meaning to "got 3 but expected 2"). Hence, the following assertion would output a message that would be confusing, since 2 was our expected result:
public void TestTwoEqualsThreeShouldFail() { // Arrange int expectedResult = 2; // Act int result = 1 + 2; // 3 !!! // Assert Assert.AreEqual(result, ...Read now
Unlock full access