예제 #1
0
        public void IsNull_DirectionStrategy(string command)
        {
            IDirectionContextStrategy directionContextStrategy = new DirectionContextStrategy();

            directionContextStrategy.SetCommand(command);
            IDirectionStrategy directionStrategy = directionContextStrategy.GetDirection();

            Assert.Null(directionStrategy);
        }
예제 #2
0
        public void IsNotNull_Rover()
        {
            ICoordinate     coordinate     = new Coordinate(5, 5);
            ISurfaceFactory surfaceFactory = new SurfaceFactory();

            surfaceFactory.CreateSurface(coordinate);

            IDirectionContextStrategy directionContextStrategy = new DirectionContextStrategy();
            IRoverPosition            position = new RoverPosition(0, 0, Direction.N);
            IRover rover = new Mars.Rover.Services.Concretes.Rover(surfaceFactory.Surface, position, directionContextStrategy);

            Assert.NotNull(rover);
        }
예제 #3
0
        public void IsEqual_Surface_5_5_And_Rover_Position_3_3_E_Execute_Command_MMRMMRMRRM_Result_Is_5_1_E()
        {
            ICoordinate     coordinate     = new Coordinate(5, 5);
            ISurfaceFactory surfaceFactory = new SurfaceFactory();

            surfaceFactory.CreateSurface(coordinate);

            IDirectionContextStrategy directionContextStrategy = new DirectionContextStrategy();
            IRoverPosition            position = new RoverPosition(3, 3, Direction.E);
            IRover rover = new Mars.Rover.Services.Concretes.Rover(surfaceFactory.Surface, position, directionContextStrategy);

            rover.Execute("MMRMMRMRRM");

            Assert.Equal("5 1 E", rover.ToString());
        }
예제 #4
0
        public void IsEqual_Surface_5_5_And_Rover_Position_1_2_N_Execute_Command_LMLMLMLMM_Result_Is_1_3_N()
        {
            ICoordinate     coordinate     = new Coordinate(5, 5);
            ISurfaceFactory surfaceFactory = new SurfaceFactory();

            surfaceFactory.CreateSurface(coordinate);

            IDirectionContextStrategy directionContextStrategy = new DirectionContextStrategy();
            IRoverPosition            position = new RoverPosition(1, 2, Direction.N);
            IRover rover = new Mars.Rover.Services.Concretes.Rover(surfaceFactory.Surface, position, directionContextStrategy);

            rover.Execute("LMLMLMLMM");

            Assert.Equal("1 3 N", rover.ToString());
        }
예제 #5
0
        public void IsThrowArgumentOutOfRangeException_Coordinate_X_and_Y_Minus(string command)
        {
            IDirectionContextStrategy directionContextStrategy = new DirectionContextStrategy();

            Assert.Throws <ArgumentNullException>(() => directionContextStrategy.SetCommand(command));
        }