Search code examples
nunit

Does NUnit contain constrant for open range check?


There is a constraint for inclusive range check (aka closed set check): Assert.That(..., Is.InRange(a, b)). I wonder if there is a built in Assert for open set check? I want to test if a value is between two others exclusive.


Solution

  • No, it only has the closed range check. For an exclusive check, you will have to spell out the comparison explicitly.

    For example...

    Assert.That(myVal, Is.GreaterThan(4).And.LessThan(10));