public void SetArenaSize_If_YLength_IsNotValid_ThrowArgumentException(int y)
        {
            // ARRANGE
            var rec = new RectangleArena();

            // ACT
            rec.SetArenaSize(1, y);
        }
        public void Given_Valid_Command_But_Invalid_Start_Position_Throw_Argument_Exception()
        {
            // ARRANGE
            var arena = new RectangleArena();
            arena.SetArenaSize(2, 2);

            var robot = new Robot(arena);

            // ACT
            new StartPositionCommand(robot).Perform("2 4 N");
        }
        public void Given_SetStartPosition_Is_Not_Valid_Then_Throw_ArgumentExcpetion()
        {
            // ARRANGE
            var arena = new RectangleArena();
            arena.SetArenaSize(1, 1);

            var robot = new Robot(arena);

            // ACT
            robot.SetStartPosition(new Position(3, 4, Orientation.East));
        }
        public void Given_Arena_Is_10X3_Then_IsValidPosition_2X2_Return_True()
        {
            // ARRANGE
            var rec = new RectangleArena();
            rec.SetArenaSize(10, 3);

            // ACT
            var result = rec.IsValidPosition(new Position(2 , 2, Orientation.East));

            // ASSERT
            Assert.True(result);
        }
        public void Given_ArenaSize_Is_5X5_Then_IsValidPosition_6X5_ReturnFalse()
        {
            // ARRANGE
            var rec = new RectangleArena();
            rec.SetArenaSize(5, 5);

            // ACT
            var result = rec.IsValidPosition(new Position(6 , 5, Orientation.East));

            // ASSERT
            Assert.False(result);
        }
        public void Given_Invalid_Command_Throw_Argument_Exception()
        {
            // ARRANGE
            var command = "L R M X";

            var arena = new RectangleArena();
            arena.SetArenaSize(5, 5);

            var robot = new Robot(arena);
            robot.SetStartPosition(new Position(0, 0, Orientation.North));

            // ACT
            new MoveCommand(robot).Perform(command);
        }
        public void Given_Valid_Command_Robot_Should_Have_Correct_Starting_Posistion()
        {
            // ARRANGE
            var arena = new RectangleArena();
            arena.SetArenaSize(2, 2);

            var robot = new Robot(arena);

            // ACT
            new StartPositionCommand(robot).Perform("0 1 E");

            // ASSERT
            Assert.AreEqual(0, robot.Position.XCoordinate);
            Assert.AreEqual(1, robot.Position.YCoordinate);
            Assert.AreEqual(Orientation.East, robot.Position.Orientation);
        }
        public void Given_SetStartPosition_Is_Valid_Then_Position_Returns_InitialValue()
        {
            // ARRANGE
            var arena = new RectangleArena();
            arena.SetArenaSize(3, 4);

            var robot = new Robot(arena);

            // ACT
            robot.SetStartPosition(new Position(2, 3, Orientation.East));

            // ASSERT
            Assert.AreEqual(2, robot.Position.XCoordinate);
            Assert.AreEqual(3, robot.Position.YCoordinate);
            Assert.AreEqual(Orientation.East, robot.Position.Orientation);
        }
        public void Given_Valid_Command_Then_Robot_Should_Have_Correct_Position()
        {
            // ARRANGE
            var command = "LRMM";

            var arena = new RectangleArena();
            arena.SetArenaSize(5, 5);

            var robot = new Robot(arena);
            robot.SetStartPosition(new Position(0, 0, Orientation.North));

            // ACT
            new MoveCommand(robot).Perform(command); 

            // ASSERT
            Assert.AreEqual(0, robot.Position.XCoordinate);
            Assert.AreEqual(2, robot.Position.YCoordinate);
            Assert.AreEqual(Orientation.North, robot.Position.Orientation);
        }
Exemplo n.º 10
0
        public void Given_Move_Is_Not_Valid_For_StartPosition_Then_Throw_InvalidOperationException()
        {
            // ARRANGE
            var arena = new RectangleArena();
            arena.SetArenaSize(1, 1);

            var robot = new Robot(arena);
            robot.SetStartPosition(new Position(1, 1, Orientation.North));

            // ACT
            robot.Move(Motion.Forward);
        }