public void Remove_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; airline_facade.CancelFlight(airline_token, demi_flight); Assert.AreEqual(airline_facade.GetAllFlights(airline_token).Count, 2); FlightHistory flightHistory = airline_facade.GetFlightHistoryByOriginalId(airline_token, flight_id); Assert.AreEqual(flightHistory.Id, 1); Assert.AreEqual(flightHistory.AirlineCompanyId, demi_flight.AirlineCompany.Id); Assert.AreEqual(flightHistory.AirlineCompanyName, demi_flight.AirlineCompany.Name); TestData.CompareDates(flightHistory.DepartureTime, demi_flight.DepartureTime); TestData.CompareDates(flightHistory.LandingTime, demi_flight.LandingTime); Assert.AreEqual(flightHistory.OriginCountryId, demi_flight.OriginCountryId); Assert.AreEqual(flightHistory.DestinationCountryId, demi_flight.DestinationCountryId); Assert.AreEqual(flightHistory.RemainingTickets, demi_flight.RemainingTickets); Assert.AreEqual(flightHistory.FlightStatus, FlightStatus.Cancelled_By_Company); }); }
public void Remove_Airline_Company_With_Flight_And_Ticket() { Execute_Test(() => { int country_id = administrator_facade.CreateNewCountry(administrator_token, TestData.Get_Countries_Data()[0]); int country_id2 = administrator_facade.CreateNewCountry(administrator_token, TestData.Get_Countries_Data()[1]); int country_id3 = administrator_facade.CreateNewCountry(administrator_token, TestData.Get_Countries_Data()[2]); AirlineCompany demi_airline_company = TestData.Get_AirlineCompanies_Data()[0]; demi_airline_company.CountryId = country_id; long airline_company_id = administrator_facade.CreateNewAirlineCompany(administrator_token, demi_airline_company); demi_airline_company.Id = airline_company_id; system.TryLogin(demi_airline_company.User.UserName, demi_airline_company.User.Password, out ILoginToken token, out FacadeBase facade); LoggedInAirlineFacade airlineFacade = facade as LoggedInAirlineFacade; LoginToken <AirlineCompany> airlineToken = token as LoginToken <AirlineCompany>; Flight demi_flight = TestData.Get_Flights_Data()[0]; long flight_id = airlineFacade.CreateFlight(airlineToken, demi_flight); demi_flight.Id = flight_id; Customer demi_customer = TestData.Get_Customers_Data()[0]; demi_customer.Id = administrator_facade.CreateNewCustomer(administrator_token, demi_customer); system.TryLogin(demi_customer.User.UserName, demi_customer.User.Password, out ILoginToken token2, out FacadeBase facade2); LoggedInCustomerFacade customerFacade = facade2 as LoggedInCustomerFacade; LoginToken <Customer> customerToken = token2 as LoginToken <Customer>; Ticket ticket = customerFacade.PurchaseTicket(customerToken, demi_flight); administrator_facade.RemoveAirline(administrator_token, demi_airline_company); Assert.AreEqual(administrator_facade.GetAllAirlineCompanies().Count, 0); Assert.AreEqual(administrator_facade.GetAllFlights().Count, 0); Assert.AreEqual(airlineFacade.GetAllTickets(airlineToken).Count, 0); Assert.AreEqual(airlineFacade.GetFlightHistoryByOriginalId(airlineToken, demi_flight.Id).Id, 1); Assert.AreEqual(customerFacade.GetTicketHistoryByOriginalId(customerToken, ticket.Id).Id, 1); }); }