public KeepIntegrationtest() { var host = new TestServer(new WebHostBuilder() .UseEnvironment("Testing") .UseStartup <Startup>()); _context = host.Host.Services.GetService(typeof(KeepNotesContext)) as KeepNotesContext; _client = host.CreateClient(); List <Notes> note1 = new List <Notes>() { new Notes { Title = "First", Text = "First sentence", PinStat = true, checklist = new List <CheckList>() { new CheckList { list = "hello" }, new CheckList { list = "brother" } }, label = new List <Label>() { new Label { label = "number1" }, new Label { label = "number2" } } }, new Notes { Title = "Second", Text = "Second sentence", PinStat = true, checklist = new List <CheckList>() { new CheckList { list = "hello2" }, new CheckList { list = "brother2" } }, label = new List <Label>() { new Label { label = "number3" }, new Label { label = "number4" } } } }; _context.Notes.AddRange(note1); _context.SaveChanges(); }
public NotesController GetController() { var optionsBuilder = new DbContextOptionsBuilder <KeepNotesContext>(); optionsBuilder.UseInMemoryDatabase <KeepNotesContext>(Guid.NewGuid().ToString()); var todocontext = new KeepNotesContext(optionsBuilder.Options); CreateTestData(optionsBuilder.Options); return(new NotesController(todocontext)); }
public KeepContext() { //var optionBuilder = new DbContextOptionsBuilder<KeepNotesContext>(); //optionBuilder.UseInMemoryDatabase("TestDB"); var optionsBuilder = new DbContextOptionsBuilder <KeepNotesContext>(); optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); var todocontext = new KeepNotesContext(optionsBuilder.Options); _controller = new NotesController(todocontext); createtestdata(todocontext); }
public void createtestdata(KeepNotesContext todocontext) { List <Notes> note1 = new List <Notes>() { new Notes { Title = "First", Text = "First sentence", PinStat = true, checklist = new List <CheckList>() { new CheckList { list = "hello" }, new CheckList { list = "brother" } }, label = new List <Label>() { new Label { label = "number1" }, new Label { label = "number2" } } }, new Notes { Title = "First", Text = "First sentence", PinStat = true, checklist = new List <CheckList>() { new CheckList { list = "hello2" }, new CheckList { list = "brother2" } }, label = new List <Label>() { new Label { label = "number3" }, new Label { label = "number4" } } } }; todocontext.AddRange(note1); todocontext.SaveChanges(); }
public NotesController(KeepNotesContext context) { _context = context; }
public void CreateTestData(DbContextOptions <KeepNotesContext> options) { using (var todocontext = new KeepNotesContext(options)) { var NotesToAdd = new List <Notes> { new Notes() { ID = 1, Text = "This is my plaintext", PinStat = true, Title = "My First Note", label = new List <Label> { new Label { label = "Label Data 1" }, new Label { label = "Label Data 2" } }, checklist = new List <CheckList> { new CheckList { list = "CheckList Data 1", }, new CheckList { list = "CheckList Data 2", } } }, new Notes() { ID = 2, Text = "PlainText 2", PinStat = false, Title = "Title 2", label = new List <Label> { new Label { label = "Label Data 3" }, new Label { label = "Label Data 4" } }, checklist = new List <CheckList> { new CheckList { list = "CheckList Data 3", }, new CheckList { list = "CheckList Data 4", } } }, }; todocontext.Notes.AddRange(NotesToAdd); todocontext.SaveChanges(); } }