Back to Nunit

ClassicAssert.Negative

docs/articles/nunit/writing-tests/assertions/classic-assertions/Assert.Negative.md

latest1.3 KB
Original Source

ClassicAssert.Negative

Asserts that a number is negative.

csharp
//true
ClassicAssert.Negative(-1);
//false
ClassicAssert.Negative(1);

All the overloads of the method are

csharp
ClassicAssert.Negative(int actual);
ClassicAssert.Negative(int actual, string message, params object[] args);

ClassicAssert.Negative(uint actual);
ClassicAssert.Negative(uint actual, string message, params object[] args);

ClassicAssert.Negative(long actual);
ClassicAssert.Negative(long actual, string message, params object[] args);

ClassicAssert.Negative(ulong actual);
ClassicAssert.Negative(ulong actual, string message, params object[] args);

ClassicAssert.Negative(decimal actual);
ClassicAssert.Negative(decimal actual, string message, params object[] args);

ClassicAssert.Negative(double actual);
ClassicAssert.Negative(double actual, string message, params object[] args);

ClassicAssert.Negative(float actual);
ClassicAssert.Negative(float actual, string message, params object[] args);

You may also use ClassicAssert.That with a Is.Negative constraint to achieve the same result.

See Also