I would like to learn how to use NUnit. I learn best by reading then playing with real code. Where can I find a small, simple C# project that uses NUnit in an exemplary manner?
6 Answers
There are many fine examples on NUnit's developer wiki.
Update as the original link is broken:
Basic examples can be found on the NUnit Documentation Page. Check out the Getting Started/QuickStart subsection, and the Assertions/* subsection.
1 Comment
From my own projects (real life, so not just demos where everything will be nice and simple :)
Both are reasonably small, and although MiscUtil is the bigger of the two, it's mostly a collection of very small, individual components.
MoreLINQ is heavily tested; MiscUtil has patchier coverage as I started it before getting into unit testing.
Comments
This should be useful...
using System.Text;
using NUnit.Framework;
namespace Test.SampleTests
{
[TestFixture]
public class CustomerTestClass
{
[TestCase(1, true)] // valid customer
[TestCase(2, true)] // valid customer
[TestCase(1123123123132, false)] // invlaid customer
public void IsValidCustomerTest(int customerId, bool isValid)
{
Assert.AreEqual(_service.ValidateCust(customerId), isValid);
}
}
}
Taken from here - https://coderwall.com/p/vwvura