Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# unit test, how to test greater than

In C# how can I unit test a greater than condition?

I.e., iIf record count is greater than 5 the test succeed.

Any help is appreciated

Code:

int actualcount = target.GetCompanyEmployees().Count
Assert. ?
like image 437
kayak Avatar asked Nov 09 '10 20:11

kayak


2 Answers

Assert.IsTrue(actualCount > 5, "The actualCount was not greater than five");
like image 188
Wix Avatar answered Oct 25 '22 13:10

Wix


It depends on which testing framework you're using.

For xUnit.net:

Assert.True(actualCount > 5, "Expected actualCount to be greater than 5.");

For NUnit:

Assert.Greater(actualCount, 5);; however, the new syntax

Assert.That(actualCount, Is.GreaterThan(5)); is encouraged.

For MSTest:

Assert.IsTrue(actualCount > 5, "Expected actualCount to be greater than 5.");

like image 18
Tobias Feil Avatar answered Oct 25 '22 14:10

Tobias Feil