public void TestIfLoadCarryOnBaggage() { var airport = new Airport(); var flightController = new FlightController(airport); Passenger passenger = new Passenger("Gosho"); Item item = new CellPhone(); Bag bag = new Bag(passenger, new Item[] { item }); passenger.Bags.Add(bag); var airplane = new LightAirplane(); List <Passenger> passengers = new List <Passenger>(); passengers.Add(passenger); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); passengers.Add(new Passenger("Gsoho")); foreach (var arg in passengers) { airplane.AddPassenger(arg); } Trip trip = new Trip("Tuk", "tam", airplane); airport.AddTrip(trip); var actualResult = flightController.TakeOff(); var expectedResult = "Tuktam4:\r\nOverbooked! Ejected Gsoho, Gosho, Gsoho, Gsoho, Gsoho\r\nConfiscated 1 bags ($700)\r\nSuccessfully transported 5 passengers from Tuk to tam.\r\nConfiscated bags: 1 (1 items) => $700"; Assert.AreEqual(expectedResult, actualResult); }
public void TestWithConfiscatedBags() { IAirport airport = new Airport(); IAirplane airplane = new LightAirplane(); IPassenger passenger = new Passenger("Pesho"); IPassenger passenger2 = new Passenger("Kolio"); IPassenger passenger3 = new Passenger("Gosho"); IPassenger passenger4 = new Passenger("Kiro"); IPassenger passenger5 = new Passenger("Ganio"); IPassenger passenger6 = new Passenger("Penka"); IItem item = new Toothbrush(); IItem item2 = new Jewelery(); IItem item3 = new Colombian(); List <IItem> items = new List <IItem>(); items.Add(item); items.Add(item2); items.Add(item3); IBag bag = new Bag(passenger, items); airplane.AddPassenger(passenger); airplane.AddPassenger(passenger2); airplane.AddPassenger(passenger3); airplane.AddPassenger(passenger4); airplane.AddPassenger(passenger5); airplane.AddPassenger(passenger6); ITrip trip = new Trip("Sofia", "London", airplane); airport.AddTrip(trip); airport.AddConfiscatedBag(bag); FlightController flight = new FlightController(airport); flight.TakeOff(); var actualResult = trip.IsCompleted; Assert.IsTrue(actualResult); }
public void TestIfAirplaneIsOverbookd() { var airplane = new LightAirplane(); Trip trip = new Trip("Tuk", "Tam", airplane); var passengers = new Passenger[10]; for (int i = 0; i < passengers.Length; i++) { passengers[i] = new Passenger("Gosho" + i); airplane.AddPassenger(passengers[i]); } airport.AddTrip(trip); var flightController = new FlightController(airport); var expectedResult = flightController.TakeOff(); var actualResult = "TukTam2:\r\nOverbooked! Ejected Gosho1, Gosho0, Gosho3, Gosho7, Gosho8\r\nConfiscated 0 bags ($0)\r\nSuccessfully transported 5 passengers from Tuk to Tam.\r\nConfiscated bags: 0 (0 items) => $0"; Assert.AreEqual(expectedResult, actualResult); }
public void Test3() { Airport airport = new Airport(); Airplane airplane = new LightAirplane(); Passenger passenger = new Passenger("Az"); List <IItem> items = new List <IItem>(); for (int i = 0; i < 30; i++) { Bag bag = new Bag(passenger, items); passenger.Bags.Add(bag); } Trip trip = new Trip("Holandiq", "Rusiq", airplane); trip.Airplane.AddPassenger(passenger); airport.AddTrip(trip); FlightController flightController = new FlightController(airport); Assert .Throws <InvalidOperationException>(() => flightController.TakeOff()); }
public void TestLoadCarryOnBaggage() { var airport = new Airport(); var airplane = new LightAirplane(); var passengers = new Passenger[10]; for (int i = 0; i < passengers.Length; i++) { passengers[i] = new Passenger("Gosho" + i); airplane.AddPassenger(passengers[i]); } for (int i = 0; i < 5; i++) { if (i % 2 == 0) { var bag = new Bag(passengers[i], new Item[] { new Colombian() }); passengers[i].Bags.Add(bag); } else { var bag = new Bag(passengers[i], new Item[] { new Toothbrush() }); passengers[i].Bags.Add(bag); } } var trip = new Trip("Tuk", "Tam", airplane); airport.AddTrip(trip); var flightController = new FlightController(airport); var actualResult = flightController.TakeOff(); var expectedResult = "TukTam3:\r\nOverbooked! Ejected Gosho1, Gosho0, Gosho3, Gosho7, Gosho8\r\nConfiscated 3 bags ($50006)\r\nSuccessfully transported 5 passengers from Tuk to Tam.\r\nConfiscated bags: 3 (3 items) => $50006"; Assert.AreEqual(expectedResult, actualResult); }
public void Test1() { IAirplane plane = new LightAirplane(); IPassenger pasenger = new Passenger("Pesho2"); plane.AddPassenger(new Passenger("Pesho1")); plane.AddPassenger(pasenger); plane.AddPassenger(new Passenger("Pesho3")); plane.AddPassenger(new Passenger("Pesho4")); plane.AddPassenger(new Passenger("Pesho5")); plane.AddPassenger(new Passenger("Pesho6")); ITrip trip = new Trip("Sofia", "London", plane); IAirport airport = new Airport(); airport.AddTrip(trip); IFlightController flightController = new FlightController(airport); IBag bag = new Bag(pasenger, new IItem[] { new Colombian() }); pasenger.Bags.Add(bag); ITrip completedTrip = new Trip("London", "Sofia", new LightAirplane()); completedTrip.Complete(); airport.AddTrip(completedTrip); string actual = flightController.TakeOff(); string expected = "SofiaLondon1:\r\nOverbooked! Ejected Pesho2\r\nConfiscated 1 bags ($50000)\r\nSuccessfully transported 5 passengers from Sofia to London.\r\nConfiscated bags: 1 (1 items) => $50000"; Assert.That(actual, Is.EqualTo(expected)); Assert.That(trip.IsCompleted, Is.True); }
public void CheckIfTripIsCompleted() { var airport = new Airport(); var flightController = new FlightController(airport); Passenger passenger = new Passenger("Gosho"); Bag bag = new Bag(passenger, new Item[] { new Colombian() }); passenger.Bags.Add(bag); var airplane = new LightAirplane(); airplane.AddPassenger(passenger); Trip trip = new Trip("Tuk", "tam", airplane); airport.AddTrip(trip); trip.Complete(); var expectedResult = flightController.TakeOff(); var actualResult = "Confiscated bags: 0 (0 items) => $0"; Assert.AreEqual(expectedResult, actualResult); }
public void TestAirplaneIsOverBookedAndThereIsConfiscatedBaggage() { var airport = new Airport(); var flightController = new FlightController(airport); var airplane = new LightAirplane(); var trip = new Trip("Sofia", "Plovdiv", airplane); airport.AddTrip(trip); var passenger1 = new Passenger("Pesho"); airplane.AddPassenger(passenger1); var passenger2 = new Passenger("Gogo"); airplane.AddPassenger(passenger2); var passenger3 = new Passenger("Miro"); airplane.AddPassenger(passenger3); var passenger4 = new Passenger("Niki"); airplane.AddPassenger(passenger4); var passenger5 = new Passenger("Lili"); airplane.AddPassenger(passenger5); var passenger6 = new Passenger("Nadia"); airplane.AddPassenger(passenger6); var items = new List <Item>(); var item1 = new Laptop(); var item2 = new Jewelery(); var item3 = new TravelKit(); var item4 = new Toothbrush(); items.Add(item1); items.Add(item2); items.Add(item3); items.Add(item4); var bag1 = new Bag(passenger1, items); var bag2 = new Bag(passenger2, items); var bag3 = new Bag(passenger3, items); var bag4 = new Bag(passenger4, items); var bag5 = new Bag(passenger5, items); passenger1.Bags.Add(bag1); passenger2.Bags.Add(bag2); passenger3.Bags.Add(bag3); passenger4.Bags.Add(bag4); passenger5.Bags.Add(bag5); var completedTrip = new Trip("Sofia", "Varna", new LightAirplane()); completedTrip.Complete(); airport.AddTrip(completedTrip); string expectedResult = "SofiaPlovdiv1:\r\nOverbooked! Ejected Gogo\r\nConfiscated 1 bags ($3333)\r\nSuccessfully transported 5 passengers from Sofia to Plovdiv.\r\nConfiscated bags: 1 (4 items) => $3333"; string actualResult = flightController.TakeOff(); //System.Console.WriteLine(); Assert.That(actualResult, Is.EqualTo(expectedResult)); Assert.That(trip.IsCompleted, Is.True); }