public IntegrationTests() { var server = new TestServer(new WebHostBuilder() .UseEnvironment("Testing") .UseStartup <Startup>()); context = server.Host.Services.GetService(typeof(todoContext)) as todoContext; _client = server.CreateClient(); context.Data.AddRange(SampleNoteinDB); context.SaveChanges(); }
public NoteService(todoContext context) { _testcontext = context; }
public NotesUnitTests() { var optionsBuilder = new DbContextOptionsBuilder <todoContext>(); optionsBuilder.UseInMemoryDatabase("TestDB"); optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); var notesService = new NoteService(new todoContext(optionsBuilder.Options)); var todocontext = new todoContext(optionsBuilder.Options); testingController = new DataController(todocontext); note = new Data { ID = 1, Title = "first", Text = "Ft", label = new List <Label> { new Label { text = "black" }, new Label { text = "green" } }, checklist = new List <Checklist> { new Checklist { text = "redbull" }, new Checklist { text = "pepsi" } }, IsPinned = true }; DeleteThisNote = new Data { ID = 3, Title = "third", Text = "Ft", label = new List <Label> { new Label { text = "blue" }, new Label { text = "green" } }, checklist = new List <Checklist> { new Checklist { text = "redbull" }, new Checklist { text = "pepsi" } }, IsPinned = true }; todocontext.Data.Add(note); todocontext.Data.Add(DeleteThisNote); todocontext.SaveChanges(); }
public DataController(todoContext context) { _context = new NoteService(context); }