Skip to content

Instantly share code, notes, and snippets.

@FoC-
Last active December 20, 2015 04:28
Show Gist options
  • Save FoC-/6070678 to your computer and use it in GitHub Desktop.
Save FoC-/6070678 to your computer and use it in GitHub Desktop.
Nunit once per assembly setup teardown
using NUnit.Framework;
using TestingClasses;
namespace Tests
{
[SetUpFixture]
public class BaseContext
{
private A _a;
[SetUp]
public void setup()
{
_a = new A();
}
[TearDown]
public void tearDown()
{
_a = null;
}
}
}
namespace Tests.n1
{
public class Test1
{
[Test]
public void it_should_be_true()
{
Assert.AreEqual(1, A.InstanceCounter);
}
}
public class Test2
{
[Test]
public void it_should_be_true()
{
Assert.AreEqual(1, A.InstanceCounter);
}
}
}
namespace Tests.n2
{
public class Test1
{
[Test]
public void it_should_be_true()
{
Assert.AreEqual(1, A.InstanceCounter);
}
}
public class Test2
{
[Test]
public void it_should_be_true()
{
Assert.AreEqual(1, A.InstanceCounter);
}
}
}
namespace TestingClasses
{
public class A
{
public static int InstanceCounter = 0;
public A()
{
InstanceCounter++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment