Beispiel #1
0
        public void Should_show_boarding_info()
        {
            var output = new StringWriter();

            Console.SetOut(output);

            _service.ShowBoardingInfo(new Pilot("Pilot"), new Officer("Officer"));

            var expectedOutput = "Boarding (Pilot: Pilot, Officer: Officer)\n\r\n";

            Assert.Equal(expectedOutput, output.ToString());
        }
Beispiel #2
0
        public void PutInTheSmartFortwo(CrewMember driver, CrewMember passenger, Place currentPlace, Place destinyPlace)
        {
            if (!CurrentPlaceHasSmartFortwo(currentPlace))
            {
                throw new Exception("The smart fortwo was not found!");
            }

            if (!driver.IsNull())
            {
                if (!DriverHasAuthorization(driver))
                {
                    throw new Exception($"{driver.Name} is not authorized to drive this vehicle");
                }
            }

            currentPlace.Remove(driver, passenger);

            var shouldPutBoth          = !passenger.IsNull() && !driver.IsNull();
            var shouldPutOnlyDriver    = !driver.IsNull() && passenger.IsNull();
            var shouldPutOnlyPassenger = !passenger.IsNull() && driver.IsNull();

            if (!shouldPutBoth && !shouldPutOnlyDriver && !shouldPutOnlyPassenger)
            {
                return;
            }

            else if (shouldPutOnlyDriver)
            {
                currentPlace.PutDriverInSmartFortwo(driver);
            }

            else if (shouldPutOnlyPassenger)
            {
                currentPlace.PutPassengerInSmartFortwo(passenger);
            }

            else
            {
                currentPlace.PutBothInSmartFortwo(driver, passenger);
            }

            _tripInformerService.ShowBoardingInfo(driver, passenger);
            _tripInformerService.ShowTripStateInfo(currentPlace, destinyPlace);
        }