コード例 #1
0
        public void Test_PlaceCommand_SetsCurrentPosition(int x, int y, Direction f)
        {
            IToyRobot toyRobot = CreateSut();

            toyRobot.Place(new RobotPosition()
            {
                X = x,
                Y = y,
                F = f
            });
            var currentPosition = toyRobot.Report();

            Assert.Equal(x, currentPosition.X);
            Assert.Equal(y, currentPosition.Y);
            Assert.Equal(f, currentPosition.F);
        }
コード例 #2
0
        public void Test_RightCommand_RotatesPerpendicularInRightDirection(int x, int y, Direction currentDirection, Direction expectedDirection)
        {
            IToyRobot toyRobot = CreateSut();

            toyRobot.Place(new RobotPosition()
            {
                X = x,
                Y = y,
                F = currentDirection
            });
            toyRobot.Right();
            var currentPosition = toyRobot.Report();

            Assert.Equal(x, currentPosition.X);
            Assert.Equal(y, currentPosition.Y);
            Assert.Equal(expectedDirection, currentPosition.F);
        }
コード例 #3
0
        public void Test_MoveCommand_OneUnitInCurrentDirection(int x1, int y1, Direction f1, int x2, int y2, Direction f2)
        {
            IToyRobot toyRobot = CreateSut();

            toyRobot.Place(new RobotPosition()
            {
                X = x1,
                Y = y1,
                F = f1
            });
            toyRobot.Move();
            var currentPosition = toyRobot.Report();

            Assert.Equal(x2, currentPosition.X);
            Assert.Equal(y2, currentPosition.Y);
            Assert.Equal(f2, currentPosition.F);
        }