예제 #1
0
        public void Should_show_state_info_with_terminal_as_current_place()
        {
            var terminal = Terminal.CreateWithSmartFortwo(new List <CrewMember>());
            var airplane = new Airplane();

            var output = new StringWriter();

            Console.SetOut(output);

            _service.ShowTripStateInfo(terminal, airplane);

            var expectedOutput = "Location: Terminal\n\r\nSmart Fortwo:   |   Driver:  Empty   |   Passenger:  Empty\n\r\nTerminal: Empty\n\r\nAirplane:\n\nTechnical Crew:   \n\nCabin Crew:   \n\nCommon Crew:   \n\r\n*******************************************************************************************\r\n";

            Assert.Equal(expectedOutput, output.ToString());
        }
예제 #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);
        }
예제 #3
0
        public void Execute()
        {
            _tripInformerService.ShowStartMessage();

            _tripInformerService.ShowTripStateInfo(_currentPlace, _destinyPlace);

            _movementService.PutInTheSmartFortwo(_currentPlace.CrewMembers.FirstOrDefault(x => x is Pilot), _currentPlace.CrewMembers.FirstOrDefault(x => x is Officer), _currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkPassenger(_currentPlace, _destinyPlace);

            Move();

            _movementService.PutInTheSmartFortwo(null, _currentPlace.CrewMembers.FirstOrDefault(x => x is Officer), _currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkPassenger(_currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkDriver(_currentPlace, _destinyPlace);

            _movementService.PutInTheSmartFortwo(_currentPlace.CrewMembers.FirstOrDefault(x => x is FlightServiceChief), _currentPlace.CrewMembers.FirstOrDefault(x => x is FlightAttendant), _currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkPassenger(_currentPlace, _destinyPlace);

            Move();

            _movementService.PutInTheSmartFortwo(null, _currentPlace.CrewMembers.FirstOrDefault(x => x is FlightAttendant), _currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkPassenger(_currentPlace, _destinyPlace);

            Move();

            _movementService.PutInTheSmartFortwo(null, _currentPlace.CrewMembers.FirstOrDefault(x => x is Pilot), _currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkPassenger(_currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkDriver(_currentPlace, _destinyPlace);

            _movementService.PutInTheSmartFortwo(_currentPlace.CrewMembers.FirstOrDefault(x => x is Policeman), _currentPlace.CrewMembers.FirstOrDefault(x => x is Prisoner), _currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkAll(_currentPlace, _destinyPlace);

            _movementService.PutInTheSmartFortwo(_currentPlace.CrewMembers.FirstOrDefault(x => x is Pilot), null, _currentPlace, _destinyPlace);

            Move();

            _movementService.PutInTheSmartFortwo(null, _currentPlace.CrewMembers.FirstOrDefault(x => x is FlightServiceChief), _currentPlace, _destinyPlace);

            Move();

            _movementService.DisembarkAll(_currentPlace, _destinyPlace);
        }