public void TakeOffShouldSuccessfullyDoAFlight()
        {
            ITrip trip = new Trip("Bolivia", "Urugay", new LightAirplane());

            airport.AddTrip(trip);

            string expectedResult = ":\r\nSuccessfully transported 0 passengers from Bolivia to Urugay.\r\nConfiscated bags: 0 (0 items) => $0";
            string actuaResult    = flightController.TakeOff();

            bool contains = actuaResult.Contains(expectedResult);

            Assert.IsTrue(contains);
        }
 public void Setup()
 {
     airport     = new Airport();
     airplane    = new LightAirplane();
     fController = new FlightController(airport);
     trip        = new Trip("Sofia", "Vidin", airplane);
     airport.AddTrip(trip);
 }
Ejemplo n.º 3
0
        public void SuccessfulTrip()
        {
            var sb         = new StringBuilder();
            var passengers = new[]
            {
                new Passenger("Ivan"),
                new Passenger("Ivan2"),
                new Passenger("Ivan3"),
                new Passenger("Ivan4"),
                new Passenger("Ivan5"),
                new Passenger("Ivan6"),
            };

            var airplane = new LightAirplane();

            foreach (var passenger in passengers)
            {
                airplane.AddPassenger(passenger);
            }

            var trip = new Trip("Sofia", "London", airplane);

            airport.AddTrip(trip);

            var bag = new Bag(passengers[1], new[] { new Colombian() });

            passengers[1].Bags.Add(bag);

            var completedTrip = new Trip("Sofia", "Varna", new LightAirplane());

            completedTrip.Complete();

            airport.AddTrip(completedTrip);

            var actualResult = flightController.TakeOff();

            sb.AppendLine("SofiaLondon1:");
            sb.AppendLine("Overbooked! Ejected Ivan2");
            sb.AppendLine("Confiscated 1 bags ($50000)");
            sb.AppendLine("Successfully transported 5 passengers from Sofia to London.");
            sb.Append("Confiscated bags: 1 (1 items) => $50000");

            Assert.That(actualResult, Is.EqualTo(sb.ToString()));
            Assert.That(trip.IsCompleted, Is.True);
        }
Ejemplo n.º 4
0
        //Creates a trip with that source and destination and adds it to the airport.
        //The Id is auto-generated from the Trip class itself.
        //The command returns "Registered trip {tripId}".

        public string RegisterTrip(string source, string destination, IAirplane airplane)
        {
            ITrip trip = new Trip(source, destination, airplane);

            airport.AddTrip(trip);
            string tripId = trip.Id;

            return($"Registered trip {tripId}");
        }
Ejemplo n.º 5
0
        public string RegisterTrip(string source, string destination, string planeType)
        {
            var airplane = airplaneFactory.CreateAirplane(planeType);

            var trip = new Trip(source, destination, airplane);

            airport.AddTrip(trip);

            return($"Registered trip {trip.Id}");
        }
        public void Test_TripIsCompleted()
        {
            trip.Complete();
            IAirplane  montanaPlane = new MediumAirplane();
            ITrip      anotherTrip  = new Trip("Vidin", "Montana", montanaPlane);
            IPassenger passenger    = new Passenger("Doko");
            IBag       bag          = new Bag(passenger, new IItem[] { new Laptop() });

            airport.AddTrip(anotherTrip);
            passenger.Bags.Add(bag);
            airplane.AddPassenger(passenger);
            montanaPlane.AddPassenger(passenger);

            string result   = fController.TakeOff();
            string expected = "Successfully transported 1 passengers from Vidin to Montana.\r\nConfiscated bags: 0 (0 items) => $0";

            Assert.That(result.Contains(expected), Is.True);
            Assert.True(trip.IsCompleted);
        }