public void ReturnNotFoundWhenGivenAIncorrectReservationId() { // Arrange var mockFlightRepo = new Mock <IFlightRepository>(); mockFlightRepo.Setup(repo => repo.Items) .Returns(MoqRepositories.GetFlights()); var mockReservationRepo = new Mock <IReservationRepository>(); mockReservationRepo.Setup(repo => repo.Items) .Returns(MoqRepositories.GetReservationWithPassengers().AsQueryable()); int reservationId = 3; var controller = new FlightsController(mockFlightRepo.Object, mockReservationRepo.Object, _mapper); // Act var result = controller.PassengersDetails(reservationId); // Assert Assert.IsType <NotFoundResult>(result); }
public void ReturnAViewResult() { // Arrange var mockFlightRepo = new Mock <IFlightRepository>(); mockFlightRepo.Setup(repo => repo.Items) .Returns(MoqRepositories.GetFlights()); var mockPassengerRepo = new Mock <IPassengerRepository>(); var mockReservationRepo = new Mock <IReservationRepository>(); mockReservationRepo.Setup(repo => repo.Items) .Returns(MoqRepositories.GetReservationWithPassengers().AsQueryable()); var controller = new FlightsAdminController(mockFlightRepo.Object, mockReservationRepo.Object, mockPassengerRepo.Object, _mapper); int reservationId = 1; // Act var result = controller.PassengersDetails(reservationId); // Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <PassengerListViewModel>( viewResult.ViewData.Model); Assert.Equal(3, model.Items.Count()); }