Ejemplo n.º 1
0
        public void AddFlight_AddingTwoDifferentFlightButWithSameFlightNumber_ShouldPassTest()
        {
            // Arrange
            AirlineOperation expected = AirlineOperation.AddingFlightFailure;
            Airline          airline  = new Airline("QWE");

            airline.AddFlight(new Flight("QWE", "WER", "ERT", "13243", new DateTime(3002, 3, 2)));

            // Act
            AirlineOperation actual = airline.AddFlight(new Flight("QWE", "RRR", "TTT", "13243", new DateTime(3000, 3, 2)));

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Airline  airline  = new Airline();
            Finance  finance  = new Finance();
            Sales    sales    = new Sales();
            Catering catering = new Catering();

            //link modules with events
            airline.FlightEvent    += finance.OnFlightEvent;
            airline.FlightEvent    += sales.OnFlightEvent;
            airline.FlightEvent    += catering.OnFlightEvent;
            catering.CateringEvent += finance.OnCateringEvent;

            //simulate app
            FlightReader  fr      = new FlightReader();
            List <Flight> flights = fr.ReadFlights();

            foreach (var f in flights)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(f);
                airline.AddFlight(f);
            }

            //check observers
            catering.PrintOrderReport();
            sales.PrintAnalysisReport();
            finance.PrintCateringReport(2021);
            finance.PrintFuelReport(2021);
        }
Ejemplo n.º 3
0
        public void CopyConstructor_InstanceOfAirlineClass_ShouldPass()
        {
            // Arrange
            Airline expected = new Airline("TEST");

            expected.AddFlight(new Flight("TEST", "AAA", "BBB", "1234", new DateTime(1987, 3, 3)));
            expected.AddFlight(new Flight("TEST", "AAA", "BBB", "1235", new DateTime(1987, 3, 3)));

            // Act
            Airline actual = new Airline(expected);

            // Assert
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.Flights[0], actual.Flights[0]);
            Assert.Equal(expected.Flights[1], actual.Flights[1]);
        }
Ejemplo n.º 4
0
        public void AddFlight_AddingThreeFlights_ShouldPassTest()
        {
            // Arrange
            Flight flight1 = new Flight("DELTA", "QWE", "RTY", "143222", new DateTime(1992, 3, 3));
            Flight flight2 = new Flight("DELTA", "QWE", "RTY", "123221", new DateTime(1992, 3, 3));
            Flight flight3 = new Flight("DELTA", "QWE", "RTY", "143220", new DateTime(1992, 3, 3));

            Airline airline = new Airline("DELTA");

            // Act
            airline.AddFlight(flight1);
            airline.AddFlight(flight2);
            airline.AddFlight(flight3);

            Assert.Equal("DELTA00001", airline.Flights[0].Information.Id);
            Assert.Equal("DELTA00002", airline.Flights[1].Information.Id);
            Assert.Equal("DELTA00003", airline.Flights[2].Information.Id);
        }
Ejemplo n.º 5
0
        public void GetFlights_ReturnsAllAirlineFlights_FlightList()
        {
            Airline testAirline = new Airline("Alaskan", 250);

            testAirline.Save();
            Flight testFlight1 = new Flight("5am", "6am", "On-Time", testAirline.GetId(), 1);
            // testFlight1.Save();
            Flight testFlight2 = new Flight("7am", "8am", "On-Time", testAirline.GetId(), 1);

            // testFlight2.Save();

            testAirline.AddFlight(testFlight1);
            testAirline.AddFlight(testFlight2);
            List <Flight> savedFlights = testAirline.GetFlights();
            List <Flight> testList     = new List <Flight> {
                testFlight1, testFlight2
            };

            Assert.Equal(testList, savedFlights);
        }
Ejemplo n.º 6
0
        public void Test_If_FlightsAreSavedToAirline()
        {
            Airline testAirline = new Airline("Alaskan", 250);

            testAirline.Save();
            Flight testFlight = new Flight("5am", "6am", "On-Time", testAirline.GetId(), 1);
            //testFlight.Save();
            Flight testFlight2 = new Flight("7am", "8am", "On-Time", testAirline.GetId(), 1);

            //testFlight2.Save();

            testAirline.AddFlight(testFlight);
            testAirline.AddFlight(testFlight2);
            List <Flight> result   = testAirline.GetFlights();
            List <Flight> testList = new List <Flight> {
                testFlight, testFlight2
            };

            Console.WriteLine("result id: {0}, {1}", result[0].GetId(), result[1].GetId());
            Console.WriteLine("testlist id: {0}, {1}", testList[0].GetId(), testList[1].GetId());

            Assert.Equal(testList, result);
        }
Ejemplo n.º 7
0
        public void Equals_ComparingTwoAirlines_ShouldPassTest()
        {
            // Arragne
            Airline airline1 = new Airline("ASD");

            airline1.AddFlight(new Flight("ASSD1", "ASD", "FDS", "123456", new DateTime(1992, 3, 2)));
            airline1.AddFlight(new Flight("ASSD2", "ASD", "FDS", "123454", new DateTime(1992, 3, 2)));
            airline1.AddFlight(new Flight("ASSD3", "ASD", "FDS", "123453", new DateTime(1992, 3, 2)));

            Airline airline2 = new Airline("ASD");

            airline2.AddFlight(new Flight("ASSD1", "ASD", "FDS", "123456", new DateTime(1992, 3, 2)));
            airline2.AddFlight(new Flight("ASSD2", "ASD", "FDS", "123454", new DateTime(1992, 3, 2)));
            airline2.AddFlight(new Flight("ASSD3", "ASD", "FDS", "123453", new DateTime(1992, 3, 2)));

            bool expected = true;

            // Act
            bool actual = airline1.Equals(airline2);

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 8
0
        public void AddFlightSectionToFlight_AddingFlightSectionToExistingFlight_ShouldPassTest()
        {
            // Arrange
            bool    expected = true;
            Airline airline  = new Airline("SSS");

            airline.AddFlight(new Flight("SSS", "DDD", "AAA", "1234", new DateTime(1999, 2, 3)));

            // Act
            bool actual = airline.AddFlightSectionToFlight(new FlightSection(SeatClass.ECONOMY, 5, 5), "1234");

            // Assert
            Assert.Equal(expected, actual);
        }