예제 #1
0
        public void TestRobotMoveOffEdgeExpectFalse()
        {
            var boardService = new BoardService(new BoardPositionConverter(), new MockPositionValidator());
            var robotService = new RobotService(boardService, new PositionValidator());

            boardService.CreateNewBoard("test", 5, 5);
            robotService.PlaceRobot("test", new Vector2(1, 4), Direction.NORTH);
            Assert.Throws <RobotOutOfBoundsException>(() => robotService.MoveForward("test"));
        }
예제 #2
0
        public void TestRobotExistsCheckExpectTrue()
        {
            var boardService = new BoardService(new BoardPositionConverter(), new MockPositionValidator());
            var robotService = new RobotService(boardService, new PositionValidator());

            boardService.CreateNewBoard("test", 5, 5);
            robotService.PlaceRobot("test", new Vector2(1, 4), Direction.NORTH);
            Assert.True(robotService.RobotExists("test"));
        }
예제 #3
0
        public void TestGetRobotWithPlacedRobot()
        {
            var boardService = new BoardService(new BoardPositionConverter(), new MockPositionValidator());
            var robotService = new RobotService(boardService, new PositionValidator());

            boardService.CreateNewBoard("test", 5, 5);
            robotService.PlaceRobot("test", new Vector2(1, 1), Direction.NORTH);
            var robot = robotService.GetRobot("test");

            Assert.NotNull(robot);
        }
예제 #4
0
        public void ReportAfterPlaceExpectSuccess()
        {
            var boardService = new BoardService(new BoardPositionConverter(), new MockPositionValidator());
            var robotService = new RobotService(boardService, new PositionValidator());

            boardService.CreateNewBoard("test", 5, 5);
            robotService.PlaceRobot("test", new Vector2(1, 1), Direction.NORTH);
            var robotReport = robotService.ReportPosition("test");

            Assert.Equal("X: 1 Y: 1 F: NORTH", robotReport);
        }
예제 #5
0
        public void RotateRobotRightExpectSuccess()
        {
            var boardService = new BoardService(new BoardPositionConverter(), new MockPositionValidator());
            var robotService = new RobotService(boardService, new PositionValidator());

            boardService.CreateNewBoard("test", 5, 5);
            robotService.PlaceRobot("test", new Vector2(1, 1), Direction.NORTH);
            robotService.Rotate("test", RotateDirection.RIGHT);
            var robot = robotService.GetRobot("test");

            Assert.Equal(Direction.EAST, robot.Direction);
        }
예제 #6
0
        public void TestRobotMoveFromDirectionExpectSuccess(Direction startingDirection, int expectedX, int expectedY)
        {
            var boardService = new BoardService(new BoardPositionConverter(), new MockPositionValidator());
            var robotService = new RobotService(boardService, new PositionValidator());

            boardService.CreateNewBoard("test", 5, 5);
            robotService.PlaceRobot("test", new Vector2(1, 1), startingDirection);
            var moveResult = robotService.MoveForward("test");

            Assert.True(moveResult);
            var newRobotPosition = robotService.GetRobot("test");

            Assert.Equal(new Vector2(expectedX, expectedY), newRobotPosition.Position);
        }