I'm an old embedded coder, new to NUnit and VS C#. I'm trying to get used to the Assert.That(obj,[EvaluationMethod]) methodology that NUnit 3.x is promoting. I'm slowly getting up to speed, but was looking for a table or list for the conversion between uS and NUnit methods.

The challenge is that the code I'm updating (and will own for the next decade or two) had its unit tests developed in the Microsoft test framework and uses Assert.[EvaluationMethod] (object) format. Trying to find info on the NUnit 3.x Assert.That(obj,[EvaluationMethod]) is somewhat challenging and making the updating of the tests a long, slow slog.


1) Is the Assert.That(obj,[EvaluationMethod]) the wave of the future, or should I leave the Assert.[EvaluationMethod] in place?

2) Where can I find more info on the various [EvaluationMethod] types that are available for the Assert.That() format, should that prove the best path forward?

1 Answer 1

  1. Yes, if you want to use nUnit the Assert.That is the future, no new features will be added to the old model according to the documentation on GitHub:

    In NUnit 3.0, assertions are written primarily using the Assert.That method, which takes constraint objects as an argument. We call this the Constraint Model of assertions.

    In earlier versions of NUnit, a separate method of the Assert class was used for each different assertion. This Classic Model is still supported but since no new features have been added to it for some time, the constraint-based model must be used in order to have full access to NUnit's capabilities.


  2. What you call Evaluation methods is what NUnit calls the Constraint Model of assertions, a full list of constraints with code examples can be found here.

You could consider to just keep using the Classic NUnit Assert Model, as it might make porting your code easier.

  • Thanks. I had found those, but (like most engineering documents) are too dense for a noob, and mostly a reminder for the experienced. I was hoping for a map, along the lines of (trivial example) ** Assert.AreEqual(a, b); -> Assert.That(a, Is.EqualTo(b)); ** The problem is when things get more complex, or collections are involved... Sounds like I'll have to earn my stripes, no shortcuts. 8) ps - what happened to the formatting options?
    – kking85743
    Commented Apr 23, 2020 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.