I have the following tests setup.
[TestClass,
Isolated]
public class TestClass
{
public TestClass()
{
}
private TestContext testContextInstance;
public TestContext TestContext
{
get { return testContextInstance; }
set { testContextInstance = value; }
}
[ClassInitialize,
Isolated]
public static void InitializeRunState(TestContext testContext)
{
Helpers.SetupMocks();
//do some class init stuff
}
[TestInitialize]
public void InitializeTestState()
{
Helpers.SetupMocks();
}
[TestMethod]
public void Test()
{
//execute test
}
}
In Helpers.SetupMocks()
method I am making a call to Isolator.Swap.AllInstances<T>()
.
This works great as long as I'm not executing a load test. As soon I configure a load test that will execute the Test
method TypeMock starts throwing this exception:
TypeMock.TypeMockException: *** Can not call Swap.AllInstances() more than once on a type.
Is there anyway to avoid this? Do I have something configured wrong?