Пример #1
0
        public void ReturnNotFoundWhenGivenAIncorrectFlightId()
        {
            // Arrange
            var mockFlightRepo = new Mock <IFlightRepository>();

            mockFlightRepo.Setup(repo => repo.Items)
            .Returns(MoqRepositories.GetFlightWithReservations());
            var mockPassengerRepo   = new Mock <IPassengerRepository>();
            var mockReservationRepo = new Mock <IReservationRepository>();
            var controller          = new FlightsAdminController(mockFlightRepo.Object, mockReservationRepo.Object, mockPassengerRepo.Object, _mapper);
            int flightId            = 3;

            // Act
            var result = controller.Details(flightId);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
Пример #2
0
        public void ReturnAViewResult()
        {
            // Arrange
            var mockFlightRepo = new Mock <IFlightRepository>();

            mockFlightRepo.Setup(repo => repo.Items)
            .Returns(MoqRepositories.GetFlightWithReservations());
            var mockReservationRepo = new Mock <IReservationRepository>();
            int flightId            = 1;
            var controller          = new FlightsController(mockFlightRepo.Object, mockReservationRepo.Object, _mapper);

            // Act
            var result = controller.Details(flightId);

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

            Assert.Equal(2, model.DetailsAboutReservations.Count());
        }