コード例 #1
0
ファイル: RoverTest.cs プロジェクト: mertturkman/Mars-Rover
        public void Test_Error_Result_When_Rover_Move(Point inPosition, Size Plateau, string inDirection,
                                                      string inMovementList)
        {
            DefineRoverCommand defineRoverCommand = new DefineRoverCommand(inPosition, Plateau, inDirection);
            MoveRoverCommand   moveRoverCommand   = new MoveRoverCommand(inMovementList);

            _commandDispatcher.Handle(defineRoverCommand);

            Assert.Throws <PlateauException>(() => _commandDispatcher.Handle(moveRoverCommand));
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: RoverTest.cs プロジェクト: mertturkman/Mars-Rover
        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);
        }