Пример #1
0
        static void RoverRunSecond(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
        {
            DefineRoverCommand defineRoverCommand = new DefineRoverCommand(new Point(3, 3), new Size(5, 5), "E");

            commandDispatcher.Handle(defineRoverCommand);

            MoveRoverCommand moveRoverCommand = new MoveRoverCommand("MMRMMRMRRM");

            commandDispatcher.Handle(moveRoverCommand);

            LocationInfoQuery locationInfoQuery = new LocationInfoQuery();
            string            locationInfo      = queryDispatcher.Handle <LocationInfoQuery, string>(locationInfoQuery);

            Console.WriteLine(locationInfo);
        }
Пример #2
0
        public void Test_Acceptance_Result_When_Rover_Move(Point inPosition, Size Plateau, string inDirection,
                                                           string inMovementList, Point outPoint, Direction outDirection)
        {
            DefineRoverCommand defineRoverCommand = new DefineRoverCommand(inPosition, Plateau, inDirection);

            _commandDispatcher.Handle(defineRoverCommand);

            MoveRoverCommand moveRoverCommand = new MoveRoverCommand(inMovementList);

            _commandDispatcher.Handle(moveRoverCommand);

            LocationInfoQuery locationInfoQuery = new LocationInfoQuery();
            string            locationInfo      = _queryDispatcher.Handle <LocationInfoQuery, string>(locationInfoQuery);
            string            outputInfo        = outPoint.X + " " + outPoint.Y + " " + outDirection.ToString("G");

            Assert.Equal(outputInfo, locationInfo);
        }