public void CancelTicket()
        {
            countryDAO.Add(new Country("Israel"));

            airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", countryDAO.GetCountryByName("Israel").ID));

            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ELAL").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));
            Flight flightOne = flightDAO.GetAll()[0];

            customerDAO.Add(new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PNUMBER", "CNUMBER"));
            customerDAO.Add(new Customer("FIRSTNAME2", "LASTNAME2", "USERNAME2", "PASSWORD2", "ADDRESS2", "PNUMBER2", "CNUMBER2"));
            Customer customerOne = customerDAO.GetAll()[0];
            Customer customerTwo = customerDAO.GetAll()[1];

            LoginToken <Customer> customerLoggedIn = new LoginToken <Customer>();

            customerLoggedIn.user = customerOne;

            ticketDAO.Add(new Ticket(flightOne.ID, customerOne.ID));
            ticketDAO.Add(new Ticket(flightOne.ID, customerTwo.ID));
            Ticket ticketOne = ticketDAO.GetAll()[0];

            flightOne = flightDAO.GetAll()[0];

            Assert.AreEqual(28, flightOne.RemainingTickets);
            facade.CancelTicket(customerLoggedIn, ticketOne);
            flightOne = flightDAO.GetAll()[0];
            Assert.AreEqual(29, flightOne.RemainingTickets);
            Assert.AreEqual(1, ticketDAO.GetAll().Count);
        }
Exemplo n.º 2
0
        public void CancelFlight()
        {
            countryDAO.Add(new Country("Israel"));

            airlineDAO.Add(new AirlineCompany("ELAL", "ELALUSERNAME", "ELALPASSEORD", countryDAO.GetCountryByName("Israel").ID));
            airlineDAO.Add(new AirlineCompany("ARKIA", "ARKIAYSERNAME", "ARKIAPASSWORD", countryDAO.GetCountryByName("Israel").ID));

            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ELAL").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));
            flightDAO.Add(new Flight(airlineDAO.GetAirlineByName("ARKIA").ID, countryDAO.GetCountryByName("Israel").ID, countryDAO.GetCountryByName("Israel").ID, new DateTime(DateTime.Now.Year + 1, 12, 2), new DateTime(DateTime.Now.Year + 1, 12, 3), 30, FlightStatus.NotDeparted));

            customerDAO.Add(new Customer("FIRSTNAME", "LASTNAME", "USERNAME", "PASSWORD", "ADDRESS", "PNUMBER", "CNUMBER"));

            ticketDAO.Add(new Ticket(flightDAO.GetAll()[0].ID, customerDAO.GetCustomerByUsername("USERNAME").ID));
            ticketDAO.Add(new Ticket(flightDAO.GetAll()[1].ID, customerDAO.GetCustomerByUsername("USERNAME").ID));

            Assert.AreEqual(2, flightDAO.GetAll().Count);
            Assert.AreEqual(2, ticketDAO.GetAll().Count);

            LoginToken <AirlineCompany> airlineLoggenIn = new LoginToken <AirlineCompany>();

            airlineLoggenIn.user = airlineDAO.GetAirlineByName("ELAL");
            facade.CancelFlight(airlineLoggenIn, flightDAO.GetAll()[0]);
            Assert.AreEqual(1, flightDAO.GetAll().Count);
            Assert.AreEqual(1, ticketDAO.GetAll().Count);
        }
        public void PurchaseTicketTest()
        {
            TicketDAOMSSQL t = new TicketDAOMSSQL();

            Assert.AreEqual(t.GetAll().Count, 0);
            Flight Flight = new Flight(TestCenter.AirlineToken.User.Id, TestCenter.AirlineToken.User.CountryCode, TestCenter.AirlineToken.User.CountryCode, new DateTime(2020, 10, 10, 10, 00, 00), new DateTime(2020, 10, 11, 10, 00, 00), 100);

            TestCenter.AirlineFacade.CreateFlight(TestCenter.AirlineToken, Flight);
            Assert.AreEqual(TestCenter.AdminFacade.GetFlightById(Flight.Id).RemainingTickets, Flight.RemainingTickets);
            TestCenter.CustomerFacade.PurchaseTicket(TestCenter.CustomerToken, Flight);
            Assert.AreEqual(t.GetAll().Count, 1);
            Assert.AreEqual(TestCenter.AdminFacade.GetFlightById(Flight.Id).RemainingTickets, Flight.RemainingTickets - 1);
        }
        public List <Tickets> GetAllTickets(LoginToken <AirlineCompany> token)
        {
            List <Tickets> tickets = new List <Tickets>();

            if (token != null)
            {
                _ticketDAO = new TicketDAOMSSQL();
                tickets    = _ticketDAO.GetAll();
            }
            return(tickets);
        }
        public void CancleTicketTest()
        {
            Flight Flight = new Flight(TestCenter.AirlineToken.User.Id, TestCenter.AirlineToken.User.CountryCode, TestCenter.AirlineToken.User.CountryCode, new DateTime(2020, 10, 10, 10, 00, 00), new DateTime(2020, 10, 11, 10, 00, 00), 100);

            TestCenter.AirlineFacade.CreateFlight(TestCenter.AirlineToken, Flight);
            Ticket ticket = new Ticket(Flight.Id, TestCenter.CustomerToken.User.Id);

            ticket.Id = TestCenter.CustomerFacade.PurchaseTicket(TestCenter.CustomerToken, Flight).Id;
            TicketDAOMSSQL t = new TicketDAOMSSQL();

            Assert.AreEqual(t.GetAll().Count, 1);
            Assert.AreEqual(Flight.RemainingTickets - 1, TestCenter.CustomerFacade.GetFlightById(Flight.Id).RemainingTickets);
            TestCenter.CustomerFacade.CancelTicket(TestCenter.CustomerToken, ticket);
            Assert.AreEqual(TestCenter.CustomerFacade.GetAllMyFlights(TestCenter.CustomerToken).Count, 0);
            Assert.AreEqual(Flight.RemainingTickets, TestCenter.CustomerFacade.GetFlightById(Flight.Id).RemainingTickets);
        }
Exemplo n.º 6
0
        public void PurchaseTicketTest()
        {
            t.ClearTables();
            t.FillDBForTest();

            AirlineCompany a = new AirlineCompany("airfrance", "airfrance", "134567", t.adminFacade.GetCountryByName(t.adminToken, "Israel").ID);

            t.adminFacade.CreateNewAirline(t.adminToken, a);
            t.airLineToken.User = a;

            Flight flight = new Flight(a.ID, a.CountryCode, a.CountryCode, new DateTime(2019, 10, 10), new DateTime(2019, 10, 10), 1);

            t.airlineFacade.CreateFlight(t.airLineToken, flight);

            Customer c = new Customer("Einat", "Mor", "Einat123", "191919", "Katzenelson", "0545552809", "000004400");

            t.adminFacade.CreateNewCustomer(t.adminToken, c);
            t.customerToken.User = c;

            t.customerFacade.PurchaseTicket(t.customerToken, flight);
            TicketDAOMSSQL ticketDAOMSSQL = new TicketDAOMSSQL();

            Assert.AreEqual(ticketDAOMSSQL.GetAll().Count, 1);
        }
Exemplo n.º 7
0
        public void TestCustomerFacade()
        {
            ResetWhatIsNeeded();
            FlyingCenterSystem flyingCenterSystem = FlyingCenterSystem.GetFlyingCenterSystem();

            //sign in as a airline company
            LoginToken <AirlineCompany> companyLoginToken     = flyingCenterSystem.AttemptLoginAirlineCompany("company", "company");
            LoggedInAirlineFacade       loggedInAirlineFacade = (LoggedInAirlineFacade)flyingCenterSystem.GetFacade(companyLoginToken);

            //create 4 flights
            DateTime now = DateTime.Now;

            loggedInAirlineFacade.CreateFlight(companyLoginToken,
                                               new Flight(-1, companyLoginToken.User.ID, 1, 3,
                                                          now.AddHours(1), now.AddHours(2), 10, 10));
            loggedInAirlineFacade.CreateFlight(companyLoginToken,
                                               new Flight(-1, companyLoginToken.User.ID, 1, 3,
                                                          now.AddHours(2), now.AddHours(3), 10, 10));
            loggedInAirlineFacade.CreateFlight(companyLoginToken,
                                               new Flight(-1, companyLoginToken.User.ID, 1, 3,
                                                          now.AddHours(3), now.AddHours(4), 10, 10));
            loggedInAirlineFacade.CreateFlight(companyLoginToken,
                                               new Flight(-1, companyLoginToken.User.ID, 1, 3,
                                                          now.AddHours(4), now.AddHours(5), 10, 10));

            IList <Flight> flights = loggedInAirlineFacade.GetFlightsByDestinationCountry(3);

            //login as the customer
            LoginToken <Customer>  customer = flyingCenterSystem.AttemptLoginCustomer("customer", "customer");
            LoggedInCustomerFacade loggedInCustomerFacade = (LoggedInCustomerFacade)flyingCenterSystem.GetFacade(customer);

            //buy a ticket for 4 flights
            loggedInCustomerFacade.PurchaseTicket(customer, flights[0]);
            loggedInCustomerFacade.PurchaseTicket(customer, flights[1]);
            loggedInCustomerFacade.PurchaseTicket(customer, flights[2]);
            loggedInCustomerFacade.PurchaseTicket(customer, flights[3]);

            TicketDAOMSSQL _ticketDAO = new TicketDAOMSSQL();
            IList <Ticket> tickets    = _ticketDAO.GetAll();

            Assert.IsTrue(LookForTicket(tickets, customer.User.ID, flights[0].ID));
            Assert.IsTrue(LookForTicket(tickets, customer.User.ID, flights[1].ID));
            Assert.IsTrue(LookForTicket(tickets, customer.User.ID, flights[2].ID));
            Assert.IsTrue(LookForTicket(tickets, customer.User.ID, flights[3].ID));

            Assert.AreEqual(4, loggedInCustomerFacade.GetAllMyFlights(customer).Count);

            loggedInCustomerFacade.CancelTicket(customer, tickets[0]);
            loggedInCustomerFacade.CancelTicket(customer, tickets[1]);
            loggedInCustomerFacade.CancelTicket(customer, tickets[2]);
            loggedInCustomerFacade.CancelTicket(customer, tickets[3]);

            tickets = _ticketDAO.GetAll();
            Assert.IsTrue(tickets.Count == 0);

            flights = loggedInAirlineFacade.GetFlightsByDestinationCountry(3);

            Assert.IsTrue(flights[0].RemainingTickets == 10);
            Assert.IsTrue(flights[1].RemainingTickets == 10);
            Assert.IsTrue(flights[2].RemainingTickets == 10);
            Assert.IsTrue(flights[3].RemainingTickets == 10);
        }