Esempio n. 1
0
        public async Task AddSection_PersistsSection()
        {
            var section = new Section
            {
                SectionString = "Section 1",
                InstructorId  = 1
            };

            using (var context = new ApplicationDbContext(Options))
            {
                var service = new SectionService(context);

                Section addedSection = await service.AddSection(section);

                Assert.AreEqual(addedSection, section);
                Assert.AreNotEqual(0, addedSection.Id);
            }

            using (var context = new ApplicationDbContext(Options))
            {
                Section retrievedSection = context.Sections.Single();
                Assert.AreEqual(section.SectionString, retrievedSection.SectionString);
                Assert.AreEqual(section.InstructorId, retrievedSection.InstructorId);
            }
        }