Пример #1
0
        public async Task TestDeleteCalendarItem()
        {
            using (var context = new BankCalendarContext(options))
            {
                // Given
                CalendarItem calendaritem1 = context.CalendarItem.First();

                // When
                CalendarController calendarController = new CalendarController(context);
                IActionResult      result             = await calendarController.DeleteCalendarItem(calendaritem1.ID) as IActionResult;

                // Then
                var okObjectResult = result as OkObjectResult;
                Assert.IsNotNull(okObjectResult);

                var model = okObjectResult.Value as CalendarItem;
                Assert.IsNotNull(model);
                Assert.AreNotEqual(0, model.ID);
                Assert.AreEqual(calendaritem1.Event, model.Event);
                Assert.AreEqual(calendaritem1.Location, model.Location);
                Assert.AreEqual(calendaritem1.Start, model.Start);
                Assert.AreEqual(calendaritem1.End, model.End);

                Assert.AreEqual(false, context.CalendarItem.Any(x => x.ID == calendaritem1.ID));
            }
        }