//[ExpectedException()]
 public void CheckNullToken()
 {
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.CancelFlight(null, new Flight());
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.GetAllTickets(null);
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.CreateFlight(null, new Flight());
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.UpdateFlight(null, new Flight());
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.ChangeMyPassword(null, "old_password", "new_password");
     });
     Assert.ThrowsException <Exception>(() =>
     {
         airlineFacade.MofidyAirlineDetails(null, new AirlineCompany());
     });
 }
        public IHttpActionResult UpdateFlight([FromBody] Flight flight)
        {
            bool   isAuthorized = false;
            bool   isUpdated    = false;
            bool   isFound      = false;
            Action act          = () =>
            {
                isAuthorized = GetInternalLoginTokenInternal <AirlineCompany>(out LoginToken <AirlineCompany> loginTokenAirline);

                if (isAuthorized)
                {
                    isUpdated = _loggedInAirlineFacade.UpdateFlight(loginTokenAirline, flight, out isFound);
                }
            };

            ProcessExceptions(act);
            if (!isAuthorized)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, $"Sorry, but you're not an Airline Company. Your accsess is denied.")));
            }

            if (!isFound)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, $"Sorry, but the flight number \"{flight.ID}\" can't be update beause it don't exists in the system in the first place.")));
            }

            if (!isUpdated)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotModified, $"Sorry, but the flight number \"{flight.ID}\" doesn't updated.")));
            }

            return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, $"The flight number \"{flight.ID}\" has been updated. Now it seems like that: \n\n {_loggedInAirlineFacade.GetFlightById(flight.ID)}\n\nEnjoy it!")));
        }
Пример #3
0
        public void UpdateFlight()
        {
            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);
            Flight flight1 = myFacadeAir.GetFlightById(flight.ID);

            flight.DepartureTime = DateTime.Now.AddDays(11);
            myFacadeAir.UpdateFlight(myTokenair, flight);
            Assert.AreNotEqual(flight.DepartureTime, flight1.DepartureTime);
        }
Пример #4
0
        public void UpdateFlight()
        {
            IList <AirlineCompany> airlines = facade.GetAllAirlineCompanies();

            flight.AirlineCompanyId = airlines[0].Id;
            flight.LandingTime      = new DateTime(2019, 11, 11, 10, 00, 00);
            facade.UpdateFlight(AirLineLogin, flight);
        }
Пример #5
0
        public IHttpActionResult UpdateFlight([FromBody] Flight flight)
        {
            LoginToken <AirlineCompany> token = GetLoginToken();

            facade.UpdateFlight(token, flight);

            return(Ok());
        }
Пример #6
0
        public void UpdateFlight()
        {
            Flights f_expected = new Flights(1, 1, 4, 7, DateTime.Now, new DateTime(2021, 07, 20), 4);

            loggedInAirline.UpdateFlight(airline, f_expected);//not working well throws exception even though the test is positive
            Flights f = loggedInAirline.GetFlightById(1);

            Assert.AreEqual(f_expected, f);
        }
Пример #7
0
        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);
        }
Пример #8
0
        public void UpdateFlight_FlightNotFound_ThrowsException()
        {
            LoggedInAirlineFacade airlineFacade = GetAirlineFacade(LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightNotFound_ThrowsException_LOGINTOKEN_USERNAME,
                                                                   LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightNotFound_ThrowsException_LOGINTOKEN_PASSWORD);
            Flight flight   = LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightNotFound_ThrowsException_UPDATED_FLIGHT_DETAILS;
            int    flightId = LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightNotFound_ThrowsException_FLIGHT_ID;

            Assert.ThrowsException <NullResultException>(new Action(() => airlineFacade.UpdateFlight(airlineFacade.LoginToken, flightId, flight)));
        }
Пример #9
0
        public void AirlineFacade_UpdateFlight()
        {
            LoggedInAirlineFacade facade = FlyingCenterSystem.GetInstance().Login(TestResource.AIRLINE_USERNAME, TestResource.AIRLINE_PASSWORD, out LoginTokenBase login) as LoggedInAirlineFacade;

            Flight flight = facade.GetFlightById(38);

            flight.DestinationCountryCode = 1;

            facade.UpdateFlight(login as LoginToken <AirlineCompany>, flight);
        }
Пример #10
0
        public IHttpActionResult UpdateAirlineCompany(int flightID, [FromBody] HTTPFlight flight)
        {
            if ((flight.AirlineCompanyID <= 0 & flight.OriginCountryID <= 0 &
                 flight.DestinationCountryID <= 0 & flight.DepartureTime == null &
                 flight.LandingTime == null & flight.RemainingTickets < 0 &
                 flight.MaxTickets <= 0))
            {
                return(BadRequest());
            }

            LoginToken <AirlineCompany> token  = (LoginToken <AirlineCompany>)Request.Properties["User"];
            LoggedInAirlineFacade       facade = (LoggedInAirlineFacade)(FlyingCenterSystem.GetFlyingCenterSystem().GetFacade(token));
            Flight original = facade.GetFlightById(flightID);

            if (!CheckUpdateFlightInput(original, flight, token, facade))
            {
                return(BadRequest());
            }

            HTTPFlight tempFlight = new HTTPFlight(original);

            if (flight.AirlineCompanyID > 0)
            {
                tempFlight.AirlineCompanyID = flight.AirlineCompanyID;
            }
            if (flight.OriginCountryID > 0)
            {
                tempFlight.OriginCountryID = flight.OriginCountryID;
            }
            if (flight.DestinationCountryID > 0)
            {
                tempFlight.DestinationCountryID = flight.DestinationCountryID;
            }
            if (flight.DepartureTime != DateTime.MinValue)
            {
                tempFlight.DepartureTime = flight.DepartureTime;
            }
            if (flight.LandingTime != DateTime.MinValue)
            {
                tempFlight.LandingTime = flight.LandingTime;
            }
            if (flight.RemainingTickets > 0)
            {
                tempFlight.RemainingTickets = flight.RemainingTickets;
            }
            if (flight.MaxTickets > 0)
            {
                tempFlight.MaxTickets = flight.MaxTickets;
            }

            facade.UpdateFlight(token, new Flight(flightID, tempFlight.AirlineCompanyID, tempFlight.OriginCountryID, tempFlight.DestinationCountryID,
                                                  tempFlight.DepartureTime, tempFlight.LandingTime, tempFlight.RemainingTickets, tempFlight.MaxTickets));

            return(Ok());
        }
Пример #11
0
        public IHttpActionResult UpdateFlight([FromBody] Flight flight)
        {
            GetLoginToken();
            if (AirLineToken != null)
            {
                F.UpdateFlight(AirLineToken, flight);
                return(Ok($"{flight.ID} has been Update!"));
            }

            return(NotFound());
        }
Пример #12
0
        public void NullUserTriesToUpdateFlightException()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "adi213", "54321");
            LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token;
            LoggedInAirlineFacade       facade     = (LoggedInAirlineFacade)facadebase;
            Flight   flight   = _flightDAO.Get(6);
            DateTime dateTime = new DateTime(2021, 1, 13, 8, 00, 00);

            flight.Departure_Time = dateTime;
            facade.UpdateFlight(null, flight);
        }
Пример #13
0
        public IHttpActionResult UpdateFlight([FromBody] Flight flight)
        {
            var loginToken = GetLoginToken();

            if (loginToken == null)
            {
                return(Unauthorized());
            }
            _facade.UpdateFlight(loginToken, flight);
            return(Ok());
        }
        public IActionResult UpdateFlight([FromBody] Flight flight)
        {
            IActionResult result = SafeExecute(() =>
            {
                int facadeIndex = RetriveFacadeIndex();
                LoggedInAirlineFacade airlineFacade = (LoggedInAirlineFacade)FlyingCenterSystem.FacadeList[facadeIndex];
                airlineFacade.UpdateFlight(airlineFacade.LoginToken, flight.Id, flight);
                return(Ok());
            });

            return(result);
        }
Пример #15
0
        public void UpdateFlight_Test()
        {
            FlightCenterSystem.Instance.Login(out FacadeBase facadebase, out ILoginToken token, "adi213", "54321");
            LoginToken <AirlineCompany> loginToken = (LoginToken <AirlineCompany>)token;
            LoggedInAirlineFacade       facade     = (LoggedInAirlineFacade)facadebase;
            Flight   flight   = _flightDAO.Get(6);
            DateTime dateTime = new DateTime(2021, 1, 13, 8, 00, 00);

            flight.Departure_Time = dateTime;
            facade.UpdateFlight(loginToken, flight);
            flight = _flightDAO.Get(6);
            Assert.AreEqual(flight.Departure_Time, dateTime);
        }
Пример #16
0
        public async Task <ActionResult <Flight> > UpdateFlight([FromBody] Flight flight)
        {
            FlightsCenterSystem.GetInstance().login(GetLoginToken().Name, GetLoginToken().Password,
                                                    out LoginToken <Object> l, out FacadeBase f);
            facade        = f as LoggedInAirlineFacade;
            token_airline = GetLoginToken();
            User u = new UserDAOPGSQL().GetAll().FirstOrDefault(_ => _.Password == token_airline.Password && _.Username == token_airline.Name);

            token_airline.User = new AirlineDAOPGSQL().GetAll().FirstOrDefault(_ => _.UserId == u.Id);
            await Task.Run(() => facade.UpdateFlight(token_airline, flight));

            return(StatusCode(200, flight));
        }
Пример #17
0
 public IHttpActionResult UpdateFlight(Flight flight)
 {
     try
     {
         LoginToken <AirlineCompany> airlineToken = new LoginToken <AirlineCompany>();
         airlineCompanyFacade.UpdateFlight(airlineToken, flight);
         return(Ok(flight));
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(BadRequest());
     }
 }
        public IHttpActionResult UpdateFlight([FromBody] Flight flight, int id)
        {
            GetLoginToken();

            try
            {
                flight.Id = id;
                airlineFacade.UpdateFlight(loginToken, flight);
                if (airlineFacade.GetFlightById(id).Id == id && id != 0)
                {
                    return(Ok(flight));
                }
                return(NotFound());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Пример #19
0
        public void Update_Flight()
        {
            Execute_Test(() =>
            {
                Flight demi_flight               = TestData.Get_Flights_Data()[0];
                long flight_id                   = airline_facade.CreateFlight(airline_token, demi_flight);
                demi_flight.Id                   = flight_id;
                demi_flight.LandingTime          = DateTime.Now.AddYears(1);
                demi_flight.LandingTime          = DateTime.Now.AddYears(1).AddDays(1);
                demi_flight.OriginCountryId      = 1;
                demi_flight.DestinationCountryId = 1;
                demi_flight.RemainingTickets     = 0;

                airline_facade.UpdateFlight(airline_token, demi_flight);

                Flight flight_from_db = airline_facade.GetFlightById((int)flight_id);

                TestData.CompareProps(flight_from_db, demi_flight, true);
            });
        }
Пример #20
0
        public IHttpActionResult UpdateFlight(Flight flight, [FromUri] int id)
        {
            LoginToken <AirlineCompany> airlineToken  = (LoginToken <AirlineCompany>)Request.Properties["airlineToken"];
            LoggedInAirlineFacade       airlineFacade = (LoggedInAirlineFacade)Request.Properties["airlineFacade"];

            if (flight == null || id <= 0)
            {
                return(Content(HttpStatusCode.NotAcceptable, "flight details haven't been filled out correctly"));
            }

            try
            {
                flight.ID = id;
                airlineFacade.UpdateFlight(airlineToken, flight);
                return(Ok($"flight {flight.ID} was created"));
            }
            catch (Exception)
            {
                return(Content(HttpStatusCode.NotFound, $"flight id {id} wasn't found"));
            }
        }
Пример #21
0
        public void UpdateFlight_FlightFound_MakesRequestedChanges()
        {
            LoggedInAirlineFacade airlineFacade = GetAirlineFacade(LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightFound_MakesRequestedChanges_LOGINTOKEN_USERNAME,
                                                                   LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightFound_MakesRequestedChanges_LOGINTOKEN_PASSWORD);
            Flight updatedFlight = LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightFound_MakesRequestedChanges_UPDATED_FLIGHT_DETAILS;
            int    flightId      = LoggedInAirlineFacadeTest_Constants.UpdateFlight_FlightFound_MakesRequestedChanges_FLIGHT_ID;
            bool   flag          = false;

            airlineFacade.UpdateFlight(airlineFacade.LoginToken, flightId, updatedFlight);
            List <Flight> flights = (List <Flight>)airlineFacade.GetAllFlightsByAirline(airlineFacade.LoginToken);

            foreach (Flight listFlight in flights)
            {
                if (listFlight.DepartureTime == updatedFlight.DepartureTime &&
                    listFlight.LandingTime == updatedFlight.LandingTime &&
                    listFlight.TotalTickets == updatedFlight.TotalTickets)
                {
                    flag = true;
                }
            }

            Assert.IsTrue(flag);
        }
Пример #22
0
        public void AirlineFacadeTest()
        {
            new TestFacade().DeleteAllTables();

            AirlineCompany testAirline = new AirlineCompany("Air One", "airone", "*****@*****.**", "555", 1);

            LoginToken <Administrator> token = new LoginToken <Administrator>()
            {
                User = new Administrator()
            };

            new LoggedInAdministratorFacade().CreateNewAirline(token, testAirline);

            testAirline.Id = new AnonymousUserFacade().GetAllAirlineCompanies()[0].Id;

            FlightCenterSystem fcs = FlightCenterSystem.GetInstance();

            LoginToken <AirlineCompany> loginToken = new LoginToken <AirlineCompany>()
            {
                User = testAirline
            };

            LoggedInAirlineFacade facade = fcs.GetFacade <AirlineCompany>(loginToken) as LoggedInAirlineFacade;

            #region Create flight

            IList <AirlineCompany> airlines = new AnonymousUserFacade().GetAllAirlineCompanies();

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.CreateFlight(null, new Flight(airlines[0].Id, 1, 2, DateTime.Now, DateTime.Now.AddHours(3), 5, 99));
                // Null token, should cause an exception to be thrown
            });

            // Airline company constraints:

            Assert.ThrowsException <InvalidFlightException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(0, 1, 2, new DateTime(2011, 11, 11), new DateTime(2011, 11, 11), 5, 99));
                // Airline company Id is 0, should cause an exception to be thrown
            });

            Assert.ThrowsException <AirlineCompanyNotFoundException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(9999, 1, 2, new DateTime(2011, 11, 11), new DateTime(2011, 11, 11), 5, 99));
                // Airline company Id doesn't exist, should cause an exception to be thrown from the sql
            });

            // Origin country constraints:

            Assert.ThrowsException <InvalidFlightException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 0, 2, new DateTime(2011, 11, 11), new DateTime(2011, 11, 11), 5, 99));
                // Origin country Id is 0, should cause an exception to be thrown
            });

            Assert.ThrowsException <CountryNotFoundException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 9999, 2, new DateTime(2011, 11, 11), new DateTime(2011, 11, 11), 5, 99));
                // Origin country Id doesn't exist, should cause an exception to be thrown from the sql
            });

            // Destination country constraints:

            Assert.ThrowsException <InvalidFlightException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 1, 0, new DateTime(2011, 11, 11), new DateTime(2011, 11, 11), 5, 99));
                // Destination country Id is 0, should cause an exception to be thrown
            });

            Assert.ThrowsException <CountryNotFoundException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 1, 9999, new DateTime(2011, 11, 11), new DateTime(2011, 11, 11), 5, 99));
                // Destination country Id doesn't exist, should cause an exception to be thrown from the sql
            });

            // Flight time constraints:

            Assert.ThrowsException <InvalidFlightException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 1, 2, new DateTime(), new DateTime(2011, 11, 11), 5, 99));
                // No departure time, should cause an exception to be thrown
            });

            Assert.ThrowsException <InvalidFlightException>(() =>
            {
                facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 1, 2, new DateTime(2011, 11, 11), new DateTime(), 5, 99));
                // No landing time, should cause an exception to be thrown
            });

            int yearNow  = DateTime.Now.Year;
            int monthNow = DateTime.Now.Month;
            int dayNow   = DateTime.Now.Day;

            facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 1, 2, new DateTime(2012, 12, 12), new DateTime(2012, 12, 12), 5, 120));
            IList <Flight> flights = facade.GetAllFlights();

            Assert.AreEqual(flights[0].AirlineCompanyId, airlines[0].Id);
            Assert.AreEqual(flights[0].OriginCountryCode, 1);
            Assert.AreEqual(flights[0].DestinationCountryCode, 2);
            Assert.AreEqual(flights[0].DepartureTime, new DateTime(2012, 12, 12));
            Assert.AreEqual(flights[0].LandingTime, new DateTime(2012, 12, 12));
            Assert.AreEqual(flights[0].RemainingTickets, 5);
            Assert.AreEqual(flights[0].TicketPrice, 120);

            #endregion

            #region Update flight

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.UpdateFlight(null, new Flight(airlines[0].Id, 3, 4, new DateTime(yearNow, monthNow, dayNow), new DateTime(yearNow, monthNow, dayNow), 10, 99));
                // Null token, should cause an exception to be thrown
            });

            flights = facade.GetAllFlights();
            facade.UpdateFlight(loginToken, new Flight(airlines[0].Id, 2, 3, new DateTime(yearNow, monthNow, dayNow), new DateTime(yearNow, monthNow, dayNow), 10, 99)
            {
                Id = flights[0].Id
            });

            flights = facade.GetAllFlights();

            Assert.AreEqual(flights[0].AirlineCompanyId, airlines[0].Id);
            Assert.AreEqual(flights[0].OriginCountryCode, 2);
            Assert.AreEqual(flights[0].DestinationCountryCode, 3);
            Assert.AreEqual(flights[0].DepartureTime, new DateTime(yearNow, monthNow, dayNow));
            Assert.AreEqual(flights[0].LandingTime, new DateTime(yearNow, monthNow, dayNow));
            Assert.AreEqual(flights[0].RemainingTickets, 10);
            Assert.AreEqual(flights[0].TicketPrice, 99);

            #endregion

            #region Change my password

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.ChangeMyPassword(null, "555", "666");
                // Null token, should cause an exception to be thrown
            });

            Assert.ThrowsException <WrongPasswordException>(() =>
            {
                facade.ChangeMyPassword(loginToken, "444", "666");
                // wrong password, should cause an exception to be thrown
            });

            facade.ChangeMyPassword(loginToken, "555", "666");

            airlines = facade.GetAllAirlineCompanies();

            Assert.AreEqual(airlines[0].Password, "666");

            #endregion

            #region Modify airline details

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.ModifyAirlineDetails(null, testAirline);
                // Null token, should cause an exception to be thrown
            });

            testAirline.Name = "Best Pilots";

            facade.ModifyAirlineDetails(loginToken, testAirline);
            airlines = facade.GetAllAirlineCompanies();

            Assert.AreEqual(airlines[0].Name, "Best Pilots");

            #endregion

            #region Get all my flights

            Assert.ThrowsException <InvalidTokenException>(() =>
            {
                facade.CreateFlight(null, new Flight(airlines[0].Id, 3, 4, new DateTime(2009, 9, 9), new DateTime(2009, 9, 9), 10, 99));
                // Null token, should cause an exception to be thrown
            });

            facade.CreateFlight(loginToken, new Flight(airlines[0].Id, 3, 4, new DateTime(yearNow, monthNow, dayNow), new DateTime(yearNow, monthNow, dayNow), 10, 99));

            flights = facade.GetAllMyFlights(loginToken);

            Assert.AreEqual(flights[0].AirlineCompanyId, airlines[0].Id);
            Assert.AreEqual(flights[0].OriginCountryCode, 2);
            Assert.AreEqual(flights[0].DestinationCountryCode, 3);
            Assert.AreEqual(flights[0].DepartureTime, new DateTime(yearNow, monthNow, dayNow));
            Assert.AreEqual(flights[0].LandingTime, new DateTime(yearNow, monthNow, dayNow));
            Assert.AreEqual(flights[0].RemainingTickets, 10);
            Assert.AreEqual(flights[0].TicketPrice, 99);

            Assert.AreEqual(flights[1].AirlineCompanyId, airlines[0].Id);
            Assert.AreEqual(flights[1].OriginCountryCode, 3);
            Assert.AreEqual(flights[1].DestinationCountryCode, 4);
            Assert.AreEqual(flights[1].DepartureTime, new DateTime(yearNow, monthNow, dayNow));
            Assert.AreEqual(flights[1].LandingTime, new DateTime(yearNow, monthNow, dayNow));
            Assert.AreEqual(flights[1].RemainingTickets, 10);
            Assert.AreEqual(flights[1].TicketPrice, 99);

            #endregion
        }