The constraint-based assert model

In NUnit 3.0 and higher assertions are primely written using the constraint-based assert model. People using NUnit before this version where used to the classic model which used constructions like this:

const int expectedValue = 2;
Assert.IsEqual(expectedValue, myObject.MyMethodReturningInt());

Can be constructed the following way using the constraint-based assert model (CBAM):

const int expectedValue = 2;
Assert.That(myObject.MyMethodReturningInt(), Is.EqualTo(expectedValue);
Read More…
Posted in NUnit at March 29th, 2024. No Comments.