예제 #1
0
        public void Delete_deletes_from_database()
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>()
                          .UseInMemoryDatabase(databaseName: "Delete_deletes_from_database")
                          .Options;

            using (var context = new DatabaseContext(options))
            {
                var scheduling = new Scheduling
                {
                    Day    = DateTime.Today,
                    Hour   = 12,
                    Status = SchedulingStatus.Active
                };

                var service = new SchedulingService(context, new SchedulingRepository(context));
                service.Add(scheduling);
                Assert.Single(context.Set <Scheduling>().ToList());

                var insertedScheduling = service.GetAll().First();

                service.Delete(insertedScheduling.Id);
                Assert.Empty(context.Set <Scheduling>().ToList());
            }
        }