Beispiel #1
0
        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();
        }
Beispiel #2
0
        public async Task TestPost()
        {
            var notes =
                new Notes()
            {
                Title     = "My First Note",
                Text      = "This is my plaintext",
                PinStat   = true,
                checklist = new List <CheckList>()
                {
                    new CheckList()
                    {
                        list = "checklist data 1",
                    }
                },
                label = new List <Label>()
                {
                    new Label()
                    {
                        label = "labeldata 1"
                    }
                }
            };
            var json          = JsonConvert.SerializeObject(notes);
            var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

            _context.SaveChanges();
            var Response = await _client.PostAsync("/api/notes", stringContent);

            var ResponseGet = await _client.GetAsync("/api/notes/3");

            var reponseString = await ResponseGet.Content.ReadAsStringAsync();

            var responsedata = JsonConvert.DeserializeObject <Notes>(reponseString);

            notes.ID = responsedata.ID;
            Assert.True(notes.Compare(responsedata));
            //ResponseGet.EnsureSuccessStatusCode();
        }
Beispiel #3
0
        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 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();
     }
 }