Exemple #1
0
 IHttpActionResult GetFlightsByDepatrureDate(DateTime departureDate)
 {
     if (anonymousUser.GetFlightsByDepatrureDate(departureDate) == null)
     {
         return(NotFound());
     }
     return(Ok((anonymousUser.GetFlightsByDepatrureDate(departureDate))));
 }
Exemple #2
0
        public void GetAllFlightsByDepartureDate()
        {
            UserRepository testUr    = new UserRepository("dad", "aes", RolesEnum.admin);
            Admin          testAdmin = new Admin("dav,", "id", 3);

            FlyingCenterSystem.GetInstance().TryLogin(ur.UserName, ur.Password, out ILogin token,
                                                      out FacadeBase facade);
            LoginToken <Admin>          myToken  = token as LoginToken <Admin>;
            LoggedInAdministratorFacade myFacade = facade as LoggedInAdministratorFacade;

            myFacade.CreateNewAdmin(myToken, testUr, testAdmin);
            Country country = new Country("Israel");

            myFacade.CreateNewCountry(myToken, country);
            AirlineCompany airlineCompany = new AirlineCompany("ElALL", 1, country.ID);
            UserRepository airlineTestUr  = new UserRepository("rad", "ass", RolesEnum.airline);

            myFacade.CreateNewAirline(myToken, airlineTestUr, airlineCompany, country);
            Flight flight = new Flight(DateTime.Now, DateTime.Now, 50, airlineCompany.ID, country.ID, country.ID);

            FlyingCenterSystem.GetInstance().TryLogin(airlineTestUr.UserName, airlineTestUr.Password, out ILogin tokenAir,
                                                      out FacadeBase facadeAir);
            LoginToken <AirlineCompany> myTokenair  = tokenAir as LoginToken <AirlineCompany>;
            LoggedInAirlineFacade       myFacadeAir = facadeAir as LoggedInAirlineFacade;

            myFacadeAir.CreateFlight(myTokenair, flight);
            AnonymousUserFacade anonymousUserFacade = new AnonymousUserFacade();
            List <Flight>       flights             = (List <Flight>)anonymousUserFacade.GetFlightsByDepatrureDate(DateTime.Now);

            Assert.IsNotNull(flights);
        }
        public void GetFlightsByDepatrureDate_Test()
        {
            AnonymousUserFacade anonymous = new AnonymousUserFacade();
            var list = anonymous.GetFlightsByDepatrureDate(new System.DateTime(2021, 01, 01));

            Assert.AreEqual(list.Count, 1);
        }
        public void AnonymouseFacade_GetFlightsByDepatrureDate_FlightsFound()
        {
            AnonymousUserFacade facade = FlyingCenterSystem.GetInstance().GetAnonymousFacade();

            IList <Flight> flights = facade.GetFlightsByDepatrureDate(TestResource.DEPARTURE_TIME);

            Assert.AreNotEqual(null, flights);

            for (int i = 0; i < flights.Count; i++)
            {
                Assert.AreEqual(TestResource.FlightsId[i], flights[i].Id);

                Assert.AreEqual(TestResource.DepartureTimes[i], flights[i].DepartureTime);

                Assert.AreEqual(TestResource.LandingTimes[i], flights[i].LandingTime);

                Assert.AreEqual(TestResource.AirlineCompaniesId[i], flights[i].AirlineCompanyId);

                Assert.AreEqual(TestResource.OriginCountryCodes[i], flights[i].OriginCountryCode);

                Assert.AreEqual(TestResource.DestinationCountryCodes[i], flights[i].DestinationCountryCode);

                Assert.AreEqual(TestResource.Vacancies[i], flights[i].RemainingTickets);
            }
        }
Exemple #5
0
        public void AnonymousFacade_GetFlightsByDepatureDate_FlightsReceived()
        {
            Flight newFlight = null;

            InitDBUnitTest.InitDB();
            Flight flight = AirlineCompanyFacadeFacade_CreateNewFlight1();
            AnonymousUserFacade anonymousFacade = GetAnonymousFacade();

            newFlight    = CreateNewFlight1();
            newFlight.ID = flight.ID;
            newFlight.AIRLINECOMPANY_ID        = flight.AIRLINECOMPANY_ID;
            newFlight.ORIGIN_COUNTRY_CODE      = flight.ORIGIN_COUNTRY_CODE;
            newFlight.DESTINATION_COUNTRY_CODE = flight.DESTINATION_COUNTRY_CODE;
            IList <Flight> flights1 = anonymousFacade.GetFlightsByDepatrureDate(newFlight.DEPARTURE_TIME);
            IList <Flight> flights2 = new List <Flight>();

            flights2.Add(newFlight);
            List <Flight> f1 = (List <Flight>)flights1;
            List <Flight> f2 = (List <Flight>)flights2;

            Assert.AreNotEqual(flights1, null);
            Assert.AreNotEqual(flights2, null);
            CollectionAssert.AreEqual(f1, f2);
            Assert.AreEqual(flights1[0].ID, flights2[0].ID);
            Assert.AreEqual(flights1[0].AIRLINECOMPANY_ID, flights2[0].AIRLINECOMPANY_ID);
            Assert.AreEqual(flights1[0].ORIGIN_COUNTRY_CODE, flights2[0].ORIGIN_COUNTRY_CODE);
            Assert.AreEqual(flights1[0].DESTINATION_COUNTRY_CODE, flights2[0].DESTINATION_COUNTRY_CODE);
            Assert.AreEqual(flights1[0].DEPARTURE_TIME, flights2[0].DEPARTURE_TIME);
            Assert.AreEqual(flights1[0].LANDING_TIME, flights2[0].LANDING_TIME);
            Assert.AreEqual(flights1[0].REMANING_TICKETS, flights2[0].REMANING_TICKETS);
            Assert.AreEqual(flights1[0].TOTAL_TICKETS, flights2[0].TOTAL_TICKETS);
        }
        public void CRUDAirlineCompanyAndAnonymousFacadeTests()
        {
            ResetWhatIsNeeded();
            LoginService ls = new LoginService();
            LoginToken <AirlineCompany> loginToken = new LoginToken <AirlineCompany>();

            ls.TryAirlineLogin("company", "company", out loginToken);
            LoggedInAirlineFacade loggedInAirlineFacade = new LoggedInAirlineFacade();
            AnonymousUserFacade   anonymousUserFacade   = new AnonymousUserFacade();

            //create flight test
            DateTime departureTime = DateTime.Now.AddDays(1);
            DateTime landingTime   = departureTime.AddDays(1).AddHours(1);
            Flight   f             = new Flight(-1, loginToken.User.ID, 1, 3, departureTime, landingTime, 10, 10);

            loggedInAirlineFacade.CreateFlight(loginToken, f);

            IList <Flight> flights = anonymousUserFacade.GetAllFlights();

            //anonymous - get all flights test
            Assert.IsTrue(flights.Count == 1);
            f = flights[0];

            //anonymous - get flights vacancies
            Dictionary <Flight, int> dict = anonymousUserFacade.GetAllFlightsVacancy();
            int remainingTickets;

            Assert.IsTrue(dict.TryGetValue(f, out remainingTickets));
            Assert.AreEqual(10, remainingTickets);

            //anonymous - get flight by ID
            Assert.AreEqual(f, anonymousUserFacade.GetFlightById(f.ID));

            //anonymous - get flight by departure date
            Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByDepatrureDate(f.DepartureTime)));

            //anonymous - get flight by landing date
            Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByLandingDate(f.LandingTime)));

            //anonymous - get flight by destination country
            Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByDestinationCountry(f.DestinationCountryID)));

            //anonymous - get flight by origin country
            Assert.IsTrue(checkForFlightInList(f, anonymousUserFacade.GetFlightsByOriginCountry(f.OriginCountryID)));

            //update flight
            Flight newFlight = new Flight(f.ID, f.AirlineCompanyID, f.OriginCountryID, f.DestinationCountryID, f.DepartureTime.AddMinutes(30), f.LandingTime.AddMinutes(30), f.RemainingTickets, f.MaxTickets);

            loggedInAirlineFacade.UpdateFlight(loginToken, newFlight);
            f = anonymousUserFacade.GetFlightById(newFlight.ID);
            Assert.IsTrue(f.DepartureTime.Equals(newFlight.DepartureTime) & f.DepartureTime.Equals(newFlight.DepartureTime));

            //cancel flight - test only the cancelling part, not the removing ticket part as there are
            //no tickets at this point
            loggedInAirlineFacade.CancelFlight(loginToken, newFlight);
            Assert.IsTrue(anonymousUserFacade.GetFlightById(newFlight.ID) == null);
        }
        public IHttpActionResult GetFlightsByDepatrureDate(DateTime departureDate)
        {
            IList <Flight> flights = facade.GetFlightsByDepatrureDate(departureDate);

            if (flights.Count > 0)
            {
                return(Ok(flights));
            }
            return(NotFound());
        }
Exemple #8
0
        public IHttpActionResult GetFlightsByDepatrureDate([FromUri] DateTime departureDate)
        {
            IList <Flight> flights = anonymousUserFacade.GetFlightsByDepatrureDate(departureDate);

            if (flights.Count == 0)
            {
                return(NotFound());
            }
            return(Ok(flights));
        }
Exemple #9
0
        public void GetFlightsByDepartureDate()
        {
            Flights        expectedF   = new Flights(1, 1, 3, 6, new DateTime(2021, 03, 26), new DateTime(2021, 04, 26), 10);
            List <Flights> expectedlis = new List <Flights>();

            expectedlis.Add(expectedF);
            List <Flights> f = (List <Flights>)anonymousUser.GetFlightsByDepatrureDate(new DateTime(2021, 03, 26));

            CollectionAssert.AreEqual(expectedlis, f);
        }
        public IHttpActionResult GetFlightsByDepartureDate([FromUri] DateTime departureDate)
        {
            AnonymousUserFacade anonymousFacade = (AnonymousUserFacade)f.GetFacade(null);

            IList <Flight> flights = anonymousFacade.GetFlightsByDepatrureDate(departureDate);

            if (flights == null || flights.Count == 0 || departureDate <= DateTime.Now)
            {
                return(NotFound());
            }
            return(Ok(flights));
        }
        public IHttpActionResult GetFlightsByDepatrureDate(DateTime departureDate)
        {
            List <Flight> flightsByDepartureDate = AnonymousFacade.GetFlightsByDepatrureDate(departureDate).ToList();

            if (flightsByDepartureDate.Count == 0)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(flightsByDepartureDate));
            }
        }
Exemple #12
0
        public void GetFlightsByDepatrureDateTest()
        {
            AnonymousUserFacade facade = FlightsCenterSystem.GetInstance().GetFacade <Anonymous>(null) as AnonymousUserFacade;

            TestData.DeleteAllData();

            flightDAOPGSQL.Add(CreateFlightForTest());

            var f_list = facade.GetFlightsByDepatrureDate(TestData.CreateFlight_DepartureTime);

            Assert.AreNotEqual(f_list, null);
            Assert.AreEqual(f_list.Count, 1);
        }
        public IHttpActionResult GetFlightsByDepartureDate(DateTime departureDate)
        {
            if (departureDate <= DateTime.Now)
            {
                return(BadRequest());
            }
            AnonymousUserFacade facade  = new AnonymousUserFacade();
            IList <Flight>      flights = facade.GetFlightsByDepatrureDate(departureDate);

            if (flights.Count == 0)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            return(Ok(flights));
        }
        public async Task <ActionResult <Flights> > GetFlightsByDepartureDate(DateTime dateTime)
        {
            IList <Flights> result = null;

            try
            {
                result = await Task.Run(() => facade.GetFlightsByDepatrureDate(dateTime));
            }
            catch (Exception ex)
            {
                return(StatusCode(400, $"{{ error: \"{ex.Message}\" }}"));
            }
            if (result == null)
            {
                return(StatusCode(204, "{ }"));
            }
            return(Ok(result));
        }