public void AddFlight_INValid_BadRequest() { var mock = new Mock <EFFlightRepository>(db);//repos FlightController obj = new FlightController(mock.Object); Flights flight = new Flights { FlightId = 1, AirlineId = 1, FromLocation = "Dehradun", ToLocation = "Dehli", Duration = 45, AvailableSeats = 100, ArrivalTime = "10:00", DepartureTime = "9:15" }; var data = obj.AddFlight(flight); var res = data as ObjectResult; Assert.AreEqual(400, res.StatusCode); }
public void AddFlight_Valid_OkRequest() { var mock = new Mock <EFFlightRepository>(db);//repos Flights flight = new Flights { FlightId = 4, AirlineId = 1, FromLocation = "Dehradun", ToLocation = "Dehli", Date = DateTime.Parse("2020-10-1T00:00:00"), Duration = 45, AvailableSeats = 100, ArrivalTime = "10:00", DepartureTime = "9:15" }; // mock.Setup(p => p.AddFlight(flight)).Returns(4); FlightController obj = new FlightController(mock.Object); // DateTime dt = Convert.ToDateTime("2020-10-18"); var data = obj.AddFlight(flight); var res = data as OkObjectResult; // Assert.AreEqual(200, res.StatusCode); Assert.IsNotNull(data); }
public void TestAddFlight() { Dump_Data(); Flight flightItem = flightsList.First(); AutoMapperConfig.Initialize(); var controller = new FlightController(_flightBLL, _airportBLL); var returnValue = controller.AddFlight(flightItem); Assert.IsNotNull(returnValue); Assert.AreEqual(returnValue.Code, "OK"); var result = controller.GetFlightList() as List <FlightModel>; Assert.IsNotNull(result); var firstItem = result.First(); Assert.AreEqual(flightItem.FuelNeeded, firstItem.FuelNeeded); Assert.AreEqual(flightItem.AirCratfFuelComsumpDistance, firstItem.AirCratfFuelComsumpDistance); Assert.AreEqual(flightItem.DepartureAirportId, firstItem.DepartureAirportId); Assert.AreEqual(flightItem.DestinationAirportId, firstItem.DestinationAirportId); }