public void ReturnFlights_WhitPriceLessThanTheInput() { // Arrange var flightServiceMock = new Mock <IFlightService>(); var airlineServiceMock = new Mock <IAirlineService>(); var collectionFlightModels = new List <FlightModel>(); for (int i = 0; i < 2; i++) { var flightModel = new FlightModel() { Id = Guid.NewGuid(), Title = "BA123" + i, Price = 50 + i, Duration = TimeSpan.Parse("01:10:00") + TimeSpan.FromHours(i), TravelClass = TravelClass.First }; collectionFlightModels.Add(flightModel); } var collectionFlighViewtModels = new List <FlightViewModel>(); flightServiceMock.Setup(x => x.GetFlightByPrice(100)).Returns(collectionFlightModels); var flightController = new FlightController(flightServiceMock.Object, airlineServiceMock.Object); // Act var result = flightController.FilteredFlights(100); // Assert Assert.IsNotNull(result); }
public void ReturnAllFlightActionMethod_WhenPriceIsLessThanZero() { // Arrange var flightServiceMock = new Mock <IFlightService>(); var airlineServiceMock = new Mock <IAirlineService>(); var flightController = new FlightController(flightServiceMock.Object, airlineServiceMock.Object); // Act var result = (RedirectToRouteResult)flightController.FilteredFlights(-1); // Assert Assert.AreEqual("AllFlights", result.RouteValues["action"]); }
public void NoReturnFlight_WhenPriceIsLessThanExistingFlightsInDatabase() { // Arrange var flightServiceMock = new Mock <IFlightService>(); var airlineServiceMock = new Mock <IAirlineService>(); var collection = new List <FlightModel>(); //var collectionFlighViewtModels = new List<FlightViewModel>(); flightServiceMock.Setup(x => x.GetFlightByPrice(10)).Returns(collection); var flightController = new FlightController(flightServiceMock.Object, airlineServiceMock.Object); // Act var result = flightController.FilteredFlights(10) as PartialViewResult; // Assert Assert.AreEqual(null, result.View); }