public void ScheduleActionCorrectlyUpdatesRepositories()
        {
            this.SetupController();

            // Arrange
            var scheduleItems = new List <ScheduleItem>();

            scheduleItems.Add(new ScheduleItem {
                ServiceTicketID = 1
            });
            //mockScheduleItemRepo.SetReturnValue("get_All", scheduleItems.AsQueryable<ScheduleItem>());
            mockScheduleItemRepo.SetReturnValue("InsertOrUpdate", null);
            mockScheduleItemRepo.SetReturnValue("Delete", null);
            mockScheduleItemRepo.ExpectAndReturn("Save", null);

            ServiceTicket ticket = new ServiceTicket {
                ID = 0
            };

            mockServiceTicketRepo.SetReturnValue("Find", ticket);
            mockServiceTicketRepo.ExpectAndReturn("Save", null);

            // Act
            controller.AssignSchedule(1, 101, 0);

            // Assert
            Assert.AreEqual(101, ticket.AssignedToID);
            mockScheduleItemRepo.Verify();
            mockServiceTicketRepo.Verify();
        }
Пример #2
0
        public void ScheduleActionCorrectlyUpdatesRepositories()
        {
            // Arrange
            var scheduleItems = new List <ScheduleItem>();

            scheduleItems.Add(new ScheduleItem {
                ServiceTicketID = 1
            });
            //mockScheduleItemRepo.SetReturnValue("get_All", scheduleItems.AsQueryable<ScheduleItem>());

            ServiceTicket ticket = new ServiceTicket {
                ID = 0
            };

            mockServiceTicketRepo.Find(Arg.Any <int>()).Returns(ticket);

            // Act
            controller.AssignSchedule(1, 101, 0);

            // Assert
            Assert.Equal(101, ticket.AssignedToID);
            mockScheduleItemRepo.Received().Save();
            mockServiceTicketRepo.Received().Save();
        }