public void MyTestInitialize() { using (ProductContext context = new ProductContext()) { context.Products.ToList().ForEach(one => context.Products.Remove(one)); context.SaveChanges(); Product p = new Product() { IsActive = true, ProductName = "Plates", ProductNumber = "001" }; context.Products.Add(p); p = new Product() { IsActive = true, ProductName = "Cups", ProductNumber = "002" }; context.Products.Add(p); p = new Product() { IsActive = false, ProductName = "Napkins", ProductNumber = "003" }; context.Products.Add(p); context.SaveChanges(); } }
public void MyTestCleanup() { using (ProductContext context = new ProductContext()) { context.Products.ToList().ForEach(one => context.Products.Remove(one)); context.SaveChanges(); } }