public void createdata(DbContextOptions <finaltodoContext> _context) { using (var g_keep_context = new finaltodoContext(_context)) { var notes = new List <Todo>() { new Todo() { id = 1, pinned = true, heading = "header1", text = "write text here", label = new List <labels> { new labels { labelname = "label1" } }, checklist = new List <checklist> { new checklist { checkname = "checklist1" } } }, new Todo() { id = 2, pinned = true, heading = "header2", text = "write text here", label = new List <labels> { new labels { labelname = "label2" } }, checklist = new List <checklist> { new checklist { checkname = "checklist1" } } } }; g_keep_context.Todo.AddRange(notes); var CountOfEntitiesBeingTracked = g_keep_context.ChangeTracker.Entries().Count(); g_keep_context.SaveChanges(); } }
public IntegrationTest() { //var host = new TestServer(new WebHostBuilder() // .UseEnvironment("Testing") // .UseStartup<Startup>()); var host = new TestServer(new WebHostBuilder().UseEnvironment("Testing") .UseStartup <Startup>()); _context = host.Host.Services.GetService(typeof(finaltodoContext)) as finaltodoContext; client = host.CreateClient(); _context.Todo.Add(TestNote1); _context.Todo.Add(TestNote2); _context.SaveChanges(); }