コード例 #1
0
        public async Task UpdateInstructorLab_UpdatesExistingInstructorLab()
        {
            var lab = new InstructorLab
            {
                Title        = "Lab 1",
                InstructorId = 1
            };

            lab.Title = "Lab Updated";
            using (var context = new ApplicationDbContext(Options))
            {
                var           service = new InstructorLabService(context);
                InstructorLab updatedInstructorLab = await service.UpdateLab(lab);

                Assert.AreEqual(lab, updatedInstructorLab);
            }

            using (var context = new ApplicationDbContext(Options))
            {
                InstructorLab retrievedInstructorLab = context.InstructorLabs.Single();
                Assert.AreEqual(lab.Id, retrievedInstructorLab.Id);
                Assert.AreEqual(lab.Title, retrievedInstructorLab.Title);
            }
        }
コード例 #2
0
        public async Task AddInstructorLab_PersistsInstructorLab()
        {
            var lab = new InstructorLab
            {
                Title        = "Lab 1",
                InstructorId = 1
            };

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

                InstructorLab addedInstructorLab = await service.AddLab(lab);

                Assert.AreEqual(addedInstructorLab, lab);
                Assert.AreNotEqual(0, addedInstructorLab.Id);
            }

            using (var context = new ApplicationDbContext(Options))
            {
                InstructorLab retrievedInstructorLab = context.InstructorLabs.Single();
                Assert.AreEqual(lab.Title, retrievedInstructorLab.Title);
            }
        }