//Notes note;

        public IntegrationTest()
        {
            var host = new TestServer(
                new WebHostBuilder()
                .UseEnvironment("Testing")
                .UseStartup <Startup>());

            _context = host.Host.Services.GetService(typeof(NotesAPIContext)) as NotesAPIContext;
            _client  = host.CreateClient();

            notes = new List <Notes>();
            notes.Add(note);
            notes.Add(note1);
            _context.AddRange(notes);
            _context.SaveChanges();
            //CreateList(notes);
        }
コード例 #2
0
        private void CreateTestData(NotesAPIContext context)
        {
            var notes = new List <Notes>();

            Notes note = new Notes();

            note.Title = "title1";
            note.Label = new List <Label>
            {
                new Label {
                    LabelName = "label1"
                },
                new Label {
                    LabelName = "label2"
                }
            };
            note.IsPlainText = true;
            note.IsPinned    = true;
            note.Content     = new List <Content>()
            {
                new Content {
                    ContentData = "content ...... .... ..."
                }
            };
            notes.Add(note);

            Notes note1 = new Notes();

            note1.Title = "title2";
            note1.Label = new List <Label>
            {
                new Label {
                    LabelName = "label21"
                },
                new Label {
                    LabelName = "label2"
                }
            };
            note1.IsPlainText = false;

            notes.Add(note1);


            Notes note2 = new Notes();

            note2.Title = "title3";
            note2.Label = new List <Label>
            {
                new Label {
                    LabelName = "label31"
                },
                new Label {
                    LabelName = "label32"
                }
            };
            note2.IsPlainText = false;
            note2.IsPinned    = true;
            notes.Add(note2);

            //{
            //        Title = "title1",
            //        Label = new List<Label>
            //        {
            //            new Label{LabelName="label1"},
            //            new Label{LabelName="label2"}
            //        },
            //        IsPlainText = true
            //    },

            //    {
            //        Title = "title2",
            //        Label = new List<Label>
            //        {
            //            new Label{LabelName="label21"},
            //            new Label{LabelName="label22"}
            //        },
            //        IsPlainText = false
            //    }
            //};

            List <Notes> temp = notes as List <Notes>;

            context.AddRange(notes);
            context.SaveChanges();

            // Console.WriteLine(notes[0].Id +" ========= "+notes[1].Id);
        }