NUnit Setup In Visual Studio And Example NUnit test case

Once installed, Within Visual Studio, Tools | Nunitit | NUnitit settings

Change NUnit-GUI Executable to install path: C:\Program Files\NUnit 2.5.5\bin\net-2.0\nunit.exe

When you want to run an NUnit test, set the NUnit project in VS.NET as startup project and navigate to Tools | Debug Nunit GUI. The Nunit test interface will then load.

From there you can execute your test cases.

Very simple example of NUnit test:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using com.company.product.bl;

namespace com.company.product.nunit
{
    [TestFixture]
    public class TestJHAServiceManager
    {
        [Test]
        public void GetJHANames()
        {
            List<string> strings = JHAServiceManager.GetJHANames("jUnit");
            Assert.IsNotEmpty(strings);
        }


        /// <summary>
        /// Gets the JHA details with invalid id.
        /// Another example where an exception is expected
        /// </summary>
        [Test]
        [ExpectedException]
        public void GetJHADetailsWithInvalidId()
        {
            JobHazardAnalysis jha = new JobHazardAnalysis()
            {
                Id = -25
            };
            jha.LoadDetails();
        }

    }
}