Last active
December 20, 2015 04:28
-
-
Save FoC-/6070678 to your computer and use it in GitHub Desktop.
Nunit once per assembly setup teardown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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