Beispiel #1
0
        public void WrapAtEdgeWhenMoveBackward(Coordinate coordinate, char direction, World world, int expectedXCoord, int expectedYCoord)
        {
            var rover = new Rover(coordinate, direction, world);

            rover.MoveBackward();

            Assert.Equal(expectedXCoord, rover.GetCoordinate().GetXCoordinate());
            Assert.Equal(expectedYCoord, rover.GetCoordinate().GetYCoordinate());
        }
Beispiel #2
0
        public void MoveBackward(int initialX, int initialY, char initialDirection, int expectedX, int expectedY, char expectedDirection)
        {
            var coordinate = new Coordinate(initialX, initialY);
            var world      = new World(5, 5);
            var rover      = new Rover(coordinate, initialDirection, world);

            rover.MoveBackward();

            Assert.Equal(expectedX, rover.GetCoordinate().GetXCoordinate());
            Assert.Equal(expectedY, rover.GetCoordinate().GetYCoordinate());
            Assert.Equal(expectedDirection, rover.GetDirection());
        }
Beispiel #3
0
        public void NotMoveBackwardIfThereIsObstacle(int xCoord, int yCoord, char direction, World world, Coordinate obstacle)
        {
            var coordinate = new Coordinate(xCoord, yCoord);

            world.SetObstacle(obstacle);
            var rover = new Rover(coordinate, direction, world);

            var exception = Assert.Throws <Exception>(() => rover.MoveBackward());

            Assert.Equal($"Bump into obstacle at {obstacle.GetXCoordinate()},{obstacle.GetYCoordinate()}", exception.Message);
            Assert.Equal(xCoord, rover.GetCoordinate().GetXCoordinate());
            Assert.Equal(yCoord, rover.GetCoordinate().GetYCoordinate());
        }