static void Main(string[] args)
        {
            var airline = new Airline();

            airline.Name = "Air India";
            airline.Code = "AI";

            var flight1 = new Flight(airline);

            flight1.FlightID             = "AI 101";
            flight1.FlightStatus         = FlightStatus.OnTime;
            flight1.DepartureAirportCode = "CCU";
            flight1.ArrivalAirportCode   = "BLR";

            var flight2 = new Flight(airline);

            flight2.FlightID             = "AI 102";
            flight2.FlightStatus         = FlightStatus.OnTime;
            flight2.DepartureAirportCode = "BLR";
            flight2.ArrivalAirportCode   = "CCU";

            var flightCollection = new FlightCollection();

            flightCollection.Flights.Add(flight1);
            flightCollection.Flights.Add(flight2);

            var flightsdesc = flightCollection.Sort("DepartureAirportCode", true);
            var flightsasc  = flightCollection.Sort("DepartureAirportCode", false);

            var flightFilter1 = flightCollection.Filter(x => x.DepartureAirportCode == "CCU" && x.ArrivalAirportCode == "BLR");
            var flightFilter2 = flightCollection.Filter(x => x.DepartureAirportCode == "BLR" && x.ArrivalAirportCode == "CCU");
        }
Exemplo n.º 2
0
        public void FlightCollectionSortTest()
        {
            var airline = new Airline()
            {
                Name = "Air India", Code = "AI"
            };
            var flight1 = new Flight(airline)
            {
                FlightID             = "AI 102",
                ArrivalAirportCode   = "CCU",
                DepartureAirportCode = "BLR",
                DepartureDateUtc     = DateTime.UtcNow,
                ArrivalDateTimeUtc   = DateTime.UtcNow.AddMinutes(60),
            };

            var flight2 = new Flight(airline)
            {
                FlightID             = "AI 103",
                ArrivalAirportCode   = "BLR",
                DepartureAirportCode = "CCU",
                DepartureDateUtc     = DateTime.UtcNow,
                ArrivalDateTimeUtc   = DateTime.UtcNow.AddMinutes(70),
            };

            var flightCollection = new FlightCollection();

            flightCollection.Flights.Add(flight1);
            flightCollection.Flights.Add(flight2);

            //Sort1
            var flights1 = flightCollection.Sort("DepartureAirportCode", true);

            Assert.AreEqual(flights1[0].DepartureAirportCode, "CCU");
            //Sort2
            var flights2 = flightCollection.Sort("ArrivalAirportCode", true);

            Assert.AreEqual(flights2[0].ArrivalAirportCode, "CCU");
            //Sort3
            var flights3 = flightCollection.Sort("FlightDurationInMinutes", false);

            Assert.AreEqual(flights3[0].FlightID, "AI 102");
        }