Ejemplo n.º 1
0
        public void FindAvailableFlights_IfThereAreAvailableFLightsReturnsList_ShouldPassTest()
        {
            // Arrange
            bool          expected = true;
            SystemManager system   = new SystemManager();

            system.CreateAirport("DES");
            system.CreateAirport("SED");

            system.CreateAirline("DE32");
            system.CreateAirline("DE33");
            system.CreateAirline("DE34");

            system.CreateFlight("DE32", "DES", "SED", 1982, 2, 2, "123");
            system.CreateSection("DE32", "123", 5, 5, SeatClass.BUSINESS);

            system.CreateFlight("DE32", "DES", "SED", 1982, 2, 2, "1234");
            system.CreateSection("DE32", "1234", 5, 5, SeatClass.BUSINESS);

            system.CreateFlight("DE33", "DES", "SED", 1982, 2, 2, "1235");
            system.CreateSection("DE33", "1235", 5, 5, SeatClass.BUSINESS);

            system.CreateFlight("DE34", "DES", "SED", 1982, 2, 2, "1236");
            system.CreateSection("DE34", "1236", 5, 5, SeatClass.BUSINESS);

            List <Flight> flightList1 = new List <Flight>();

            flightList1.Add(new Flight("DE32", "DES", "SED", "123", new DateTime(1982, 2, 2)));
            flightList1[0].ChangeFlightInformationId("DE3200001");
            flightList1.Add(new Flight("DE32", "DES", "SED", "1234", new DateTime(1982, 2, 2)));
            flightList1[1].ChangeFlightInformationId("DE3200002");
            flightList1.Add(new Flight("DE33", "DES", "SED", "1235", new DateTime(1982, 2, 2)));
            flightList1[2].ChangeFlightInformationId("DE3300001");
            flightList1.Add(new Flight("DE34", "DES", "SED", "1236", new DateTime(1982, 2, 2)));
            flightList1[3].ChangeFlightInformationId("DE3400001");

            // Act
            List <Flight> flightList2 = system.FindAvailableFlights("DES", "SED");

            bool actual = true;

            for (int i = 0; i < flightList1.Count; i++)
            {
                if (!flightList1[i].Equals((flightList2[i])))
                {
                    actual = false;
                    break;
                }
            }

            // Assert
            Assert.Equal(expected, actual);
            Assert.Equal(flightList1.Count, flightList2.Count);
        }
Ejemplo n.º 2
0
        public void BookSeat_BookAValidAvailableSeat_ShouldPassTest()
        {
            // Arrange
            bool          expected = true;
            SystemManager system   = new SystemManager();

            system.CreateAirport("AAA");
            system.CreateAirport("BBB");

            system.CreateAirline("ASD");

            system.CreateFlight("ASD", "AAA", "BBB", 1972, 6, 4, "1543");

            system.CreateSection("ASD", "1543", 4, 4, SeatClass.BUSINESS);

            // Act
            system.BookSeat("ASD", "1543", SeatClass.BUSINESS, 2, 'B');
            bool actual = system
                          .AirlinesReference[0]
                          .FlightsReference[0]
                          .FlightSectionsReference[0]
                          .Seats[5].IsBooked;

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 3
0
        private void sectionAdd_Click(object sender, EventArgs e)
        {
            txtConsole.Clear();
            SeatClass seatClass;

            Enum.TryParse(seatClassCombo1.SelectedValue.ToString(), out seatClass);
            res.CreateSection(airlineCombo2.Text, flightCombo1.Text, decimal.ToInt32(rowPicker.Value), decimal.ToInt32(rowPicker.Value), seatClass);
        }
Ejemplo n.º 4
0
        public void CreateSection_CreateSectionForUnexistingAirline_ShouldPassTest()
        {
            // Arrange
            SystemManagerOperation expected      = SystemManagerOperation.UnexistingAirlineFailure;
            SystemManager          systemManager = new SystemManager();

            // Act
            SystemManagerOperation actual = systemManager.CreateSection("QWE", "1234", 4, 5, SeatClass.ECONOMY);

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 5
0
        public void BookSeat_BookASeatToUnexistingSection_ShouldPassTest()
        {
            // Arrange
            SystemManagerOperation expected = SystemManagerOperation.UnexsistingSeatClassFailure;
            SystemManager          system   = new SystemManager();

            system.CreateAirport("AAA");
            system.CreateAirport("BBB");

            system.CreateAirline("ASD");

            system.CreateFlight("ASD", "AAA", "BBB", 1972, 3, 2, "1543");

            system.CreateSection("ASD", "1543", 5, 4, SeatClass.ECONOMY);
            system.CreateSection("ASD", "1543", 5, 4, SeatClass.FIRST);

            // Act
            SystemManagerOperation actual = system.BookSeat("ASD", "1543", SeatClass.BUSINESS, 5, 'A');

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 6
0
        public void CreateSection_CreateValidFlightSection_ShouldPassTest()
        {
            // Arrange
            SystemManager systemManager = new SystemManager();

            systemManager.CreateAirline("QWE");
            systemManager.CreateAirport("WER");
            systemManager.CreateAirport("REW");
            systemManager.CreateFlight("QWE", "WER", "REW", 1872, 2, 2, "1234");

            FlightSection expected = new FlightSection(SeatClass.ECONOMY, 4, 5);

            // Act
            systemManager.CreateSection("QWE", "1234", 4, 5, SeatClass.ECONOMY);
            FlightSection actual = systemManager.Airlines[0].Flights[0].FlightSections[0];

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 7
0
        public void BookSeat_BookASeatThatIsUnexisting_ShouldPassTest()
        {
            // Arrange
            SystemManagerOperation expected = SystemManagerOperation.BookingSeatFailure;
            SystemManager          system   = new SystemManager();

            system.CreateAirport("AAA");
            system.CreateAirport("BBB");

            system.CreateAirline("ASD");

            system.CreateFlight("ASD", "AAA", "BBB", 1972, 5, 5, "1543");

            system.CreateSection("ASD", "1543", 3, 2, SeatClass.BUSINESS);

            // Act
            SystemManagerOperation actual = system.BookSeat("ASD", "1543", SeatClass.BUSINESS, 5, 'B');

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 8
0
        public void FinalTests_ShouldPassTest()
        {
            SystemManager res = new SystemManager();

            //Create airports
            res.CreateAirport("DEN");
            res.CreateAirport("DFW");
            res.CreateAirport("LON");
            res.CreateAirport("JPN");

            try
            {
                res.CreateAirport("DE"); //invalid
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }

            res.CreateAirport("DEH");
            res.CreateAirport("DEN"); //invalid
            res.CreateAirport("NCE");

            try
            {
                res.CreateAirport("TRIord9"); //invalid
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }

            res.CreateAirport("DEN"); //invalid

            //Create airlines
            res.CreateAirline("DELTA");
            res.CreateAirline("AMER");
            res.CreateAirline("JET");

            res.CreateAirline("DELTA"); //invalid
            res.CreateAirline("SWEST");
            res.CreateAirline("AMER");  //invalid
            res.CreateAirline("FRONT");

            try
            {
                res.CreateAirline("FRONTIER"); //invalid
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }

            //Create flights
            res.CreateFlight("DELTA", "DEN", "LON", 2009, 10, 10, "123");
            res.CreateFlight("DELTA", "DEN", "DEH", 2009, 8, 8, "567");
            res.CreateFlight("DELTA", "DEN", "NCE", 2010, 9, 8, "567"); //invalid
            res.CreateFlight("JET", "LON", "DEN", 2009, 5, 7, "123");
            res.CreateFlight("AMER", "DEN", "LON", 2010, 10, 1, "123");
            res.CreateFlight("JET", "DEN", "LON", 2010, 6, 10, "786");
            res.CreateFlight("JET", "DEN", "LON", 2009, 1, 12, "909");

            //Create sections
            res.CreateSection("JET", "123", 2, 2, SeatClass.ECONOMY);
            res.CreateSection("JET", "123", 1, 3, SeatClass.ECONOMY); //invalid
            res.CreateSection("JET", "123", 2, 3, SeatClass.FIRST);
            res.CreateSection("DELTA", "123", 1, 1, SeatClass.BUSINESS);
            res.CreateSection("DELTA", "123", 1, 2, SeatClass.ECONOMY);
            res.CreateSection("SWSERTT", "123", 5, 5, SeatClass.ECONOMY); //invalid

            res.DisplaySystemDetails();

            res.FindAvailableFlights("DEN", "LON");

            // Book seats
            res.BookSeat("DELTA", "123", SeatClass.BUSINESS, 1, 'A');
            res.BookSeat("DELTA", "123", SeatClass.ECONOMY, 1, 'A');
            res.BookSeat("DELTA", "123", SeatClass.ECONOMY, 1, 'B');
            res.BookSeat("DELTA", "123", SeatClass.BUSINESS, 1, 'A'); //already booked

            res.DisplaySystemDetails();

            res.FindAvailableFlights("DEN", "LON");
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            SystemManager res = new SystemManager();

            res.CreateAirport("DEN");
            res.CreateAirport("DFW");
            res.CreateAirport("LON");
            res.CreateAirport("JPN");
            // Invalid.
            res.CreateAirport("DE");
            res.CreateAirport("DEH");
            res.CreateAirport("DEN");
            res.CreateAirport("NCE");
            // Invalid.
            res.CreateAirport("TRIord9");
            res.CreateAirport("DEN");

            res.CreateAirline("DELTA");
            res.CreateAirline("AMER");
            res.CreateAirline("JET");
            // Already exists.
            res.CreateAirline("DELTA");
            res.CreateAirline("SWEST");
            // Already exists.
            res.CreateAirline("AMER");
            res.CreateAirline("FRONT");
            // Invalid
            res.CreateAirline("FRONTIER");

            res.CreateFlight("DELTA", "DEN", "LON", 2009, 10, 10, "123");
            res.CreateFlight("DELTA", "DEN", "DEH", 2009, 8, 8, "567");
            // Invalid.
            res.CreateFlight("DELTA", "DEN", "NCE", 2010, 9, 8, "567");
            res.CreateFlight("JET", "LON", "DEN", 2009, 5, 7, "123");
            res.CreateFlight("AMER", "DEN", "LON", 2010, 10, 1, "123");
            res.CreateFlight("JET", "DEN", "LON", 2010, 6, 10, "786");
            res.CreateFlight("JET", "DEN", "LON", 2009, 1, 12, "909");
            res.CreateFlight("JET", "DEN", "LON", 2009, 1, 12, "909");

            // Create sections.
            res.CreateSection("JET", "123", 2, 2, SeatClass.Economy);
            // Invalid for me.
            res.CreateSection("JET", "123", 1, 3, SeatClass.Economy);
            res.CreateSection("JET", "123", 2, 3, SeatClass.First);
            res.CreateSection("DELTA", "123", 1, 1, SeatClass.Business);
            res.CreateSection("DELTA", "123", 1, 2, SeatClass.Economy);
            // Invalid.
            res.CreateSection("SWSERTT", "123", 5, 5, SeatClass.Economy);

            res.DisplaySystemDetails();

            res.FindAvailableFlights("DEN", "LON");

            res.BookSeat("DELTA", "123", SeatClass.Business, 1, 'A');
            res.BookSeat("DELTA", "123", SeatClass.Economy, 1, 'A');
            res.BookSeat("DELTA", "123", SeatClass.Economy, 1, 'B');
            // Already booked.
            res.BookSeat("DELTA", "123", SeatClass.Business, 1, 'A');

            res.DisplaySystemDetails();

            res.FindAvailableFlights("DEN", "LON");
            Console.ReadKey();
        }