Exemplo n.º 1
0
        public void TestUpdateFlight()
        {
            Flight flightItem = flightsList.First();

            AutoMapperConfig.Initialize();
            var controller = new FlightController(_flightBLL, _airportBLL);

            flightItem.DepartureAirportId          = 5;
            flightItem.DestinationAirportId        = 10;
            flightItem.FlightTime                  = 2;
            flightItem.AirCratfFuelComsumpDistance = 400;
            flightItem.TakeOffEffort               = 50;

            var result = controller.UpdadteFlight(flightItem);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Code, "OK");

            FlightModel model = controller.GetFlightById(flightItem.Id);

            Assert.AreEqual(flightItem.FlightTime, model.FlightTime);
            Assert.AreEqual(flightItem.TakeOffEffort, model.TakeOffEffort);
            Assert.AreEqual(flightItem.AirCratfFuelComsumpDistance, model.AirCratfFuelComsumpDistance);
            Assert.AreEqual(flightItem.DepartureAirportId, model.DepartureAirportId);
            Assert.AreEqual(flightItem.DestinationAirportId, model.DestinationAirportId);
        }
Exemplo n.º 2
0
        public void GetFlightById_INValid_BadRequest()
        {
            var mock             = new Mock <EFFlightRepository>(db);//repos
            FlightController obj = new FlightController(mock.Object);
            var data             = obj.GetFlightById(0);
            var res = data as ObjectResult;

            Assert.AreEqual(400, res.StatusCode);
        }
Exemplo n.º 3
0
        public void TestGetFlightById()
        {
            AutoMapperConfig.Initialize();

            Flight flightItem = flightsList[0];
            var    controller = new FlightController(_flightBLL, _airportBLL);
            var    result     = controller.GetFlightById(flightItem.Id) as FlightModel;

            Assert.IsNotNull(result);

            Assert.AreEqual(flightItem.FuelNeeded, result.FuelNeeded);
            Assert.AreEqual(flightItem.AirCratfFuelComsumpDistance, result.AirCratfFuelComsumpDistance);
            Assert.AreEqual(flightItem.DepartureAirportId, result.DepartureAirportId);
            Assert.AreEqual(flightItem.DestinationAirportId, result.DestinationAirportId);
        }