Пример #1
0
        public void IndexViewNameEqualIndex()
        {
            // Arrange
            var mock = new Mock <IRepository>();

            mock.Setup(repo => repo.GetAllBookingTable()).Returns(GetTestBookings());
            var controller = new BookingController(mock.Object);
            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.Equal("Index", result?.ViewName);
        }
Пример #2
0
        public void IndexReturnsAViewResultWithAListOfBookings()
        {
            // Arrange
            var mock = new Mock <IRepository>();

            mock.Setup(repo => repo.GetAllBookingTable()).Returns(GetTestBookings());
            var controller = new BookingController(mock.Object);

            // Act
            var result = controller.Index();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <BookingTable> >(viewResult.Model);

            Assert.Equal(GetTestBookings().Count, model.Count());
        }