Click here to Skip to main content
15,886,258 members
Articles / DevOps / Testing

Unit Testing Using NUnit

Rate me:
Please Sign up or sign in to vote.
4.83/5 (64 votes)
25 Jul 2013GPL35 min read 461.1K   10.6K   125  
Unit Testing using NUnit.
using System;
using NUnit;
using NUnit_Application;
using NUnit.Framework;

namespace NUnit_Application.Test
{
    [TestFixture]
    public class TestClass
    {
        [TestCase]
        public void AddTest()
        {
            MathsHelper helper = new MathsHelper();
            int result = helper.Add(20, 10);
            Assert.AreEqual(40, result);
        }

        [TestCase]
        public void SubtractTest()
        {
            MathsHelper helper = new MathsHelper();
            int result = helper.Subtract(20, 10);
            Assert.AreEqual(10, result);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
Nepal Nepal
I am a software developer with knowledge of C, C++, PHP, MySQL, C#.Net, ADO.Net, MSSQL Server, Crystal Reports, Asp.Net, Oracle, Asp.Net MVP, MVC, jQuery, javascript, WebService, WCF, Entity Framework and so on. I love to play on New Technologies.

Comments and Discussions