NUnit Test template
See dual MSTest/NUnit test class.
/*
* 1. Reference Nunit.Framework dll
* 2. Reference project to test
* 3. Import/using project namespace
*/
using NUnit.Framework;
using System;
[TestFixture]
public class Test1
{
#region Tests
[Test]
public void TestMethod()
{
// TODO: Add your test.
//Assert.IsTrue(true);
}
/// <summary>
/// Test an exception
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestException()
{
int r = StaticClass.CauseException(null);
}
[TestMethod]
[RowTest] /* Since NUnit 2.4.7, Nunit includes RowTest */
[Row(1)]
[Row(3)]
public void TestRowTest(int i)
{
Assert.LessOrEqual(i, 3);
}
#endregion
#region Setup/TearDown
/// <summary>
/// Initialise/ open resources.
/// </summary>
[TestFixtureSetUp]
public void Init()
{
// TODO: Add Init code.
}
/// <summary>
/// Release resources/ reset. This method runs once at the end.
/// </summary>
[TestFixtureTearDown]
public void Dispose()
{
// TODO: Add tear down code.
}
#endregion
}
* 1. Reference Nunit.Framework dll
* 2. Reference project to test
* 3. Import/using project namespace
*/
using NUnit.Framework;
using System;
[TestFixture]
public class Test1
{
#region Tests
[Test]
public void TestMethod()
{
// TODO: Add your test.
//Assert.IsTrue(true);
}
/// <summary>
/// Test an exception
/// </summary>
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void TestException()
{
int r = StaticClass.CauseException(null);
}
[TestMethod]
[RowTest] /* Since NUnit 2.4.7, Nunit includes RowTest */
[Row(1)]
[Row(3)]
public void TestRowTest(int i)
{
Assert.LessOrEqual(i, 3);
}
#endregion
#region Setup/TearDown
/// <summary>
/// Initialise/ open resources.
/// </summary>
[TestFixtureSetUp]
public void Init()
{
// TODO: Add Init code.
}
/// <summary>
/// Release resources/ reset. This method runs once at the end.
/// </summary>
[TestFixtureTearDown]
public void Dispose()
{
// TODO: Add tear down code.
}
#endregion
}