I\'ve used NUnit with VS2008, and now am adapting to MSTest on VS2010. I used to be able to create an object in TestSetup() and dispose of it in TestCleanup(), and have the
Here is a simple example using TestInitialize and TestCleanup.
[TestClass]
public class UnitTest1
{
private NorthwindEntities context;
[TestInitialize]
public void TestInitialize()
{
this.context = new NorthwindEntities();
}
[TestMethod]
public void TestMethod1()
{
Assert.AreEqual(92, this.context.Customers.Count());
}
[TestCleanup]
public void TestCleanup()
{
this.context.Dispose();
}
}