Ejemplo n.º 1
0
        public void Should_ReturnSuccess_When_GivenTheSpecifiedInputs()
        {
            var movements = new List <Movement>
            {
                Movement.Right,
                Movement.Move,
                Movement.Move,
                Movement.Move
            };

            var mines = new List <IMine>();

            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(3, 1));
            _exitSetCommand.Set(_board, _exit);
            _exitSetCommand.Execute();

            _turtleSetCommand = new TurtleSetCommand(new TurtlePoint(0, 1, Direction.North));
            _turtleSetCommand.Set(_board, _turtle);
            _turtleSetCommand.Execute();

            _turtleMoveCommand = new TurtleMoveCommand(movements);
            _turtleMoveCommand.Set(_turtle, mines, _exit);
            _turtleMoveCommand.Execute();

            Assert.Equal("Success", _turtle.Result);
        }
Ejemplo n.º 2
0
        public void Should_ThrowPointValidationException_When_TheAppHasInvalidPoints()
        {
            var movements = new List <Movement>
            {
                Movement.Right,
                Movement.Move,
                Movement.Move,
                Movement.Move,
                Movement.Move,
                Movement.Move,
                Movement.Move
            };

            var mines = new List <IMine>();

            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(3, 1));
            _exitSetCommand.Set(_board, _exit);
            _exitSetCommand.Execute();

            _turtleSetCommand = new TurtleSetCommand(new TurtlePoint(0, 1, Direction.North));
            _turtleSetCommand.Set(_board, _turtle);
            _turtleSetCommand.Execute();

            _turtleMoveCommand = new TurtleMoveCommand(movements);
            _turtleMoveCommand.Set(_turtle, mines, _exit);
            _turtleMoveCommand.Execute();

            var exception = Assert.Throws <PointValidationException>(() => _turtleMoveCommand.Execute());

            Assert.Equal("Turtle cannot go out of board!", exception.Message);
        }
Ejemplo n.º 3
0
        public void Should_CreateTheIdenticalBoardWithTheGivenSizeParameters_When_TheCommandSizeParametersAreGiven()
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            Assert.Equal(5, _board.Size.MaxX);
            Assert.Equal(4, _board.Size.MaxY);
        }
Ejemplo n.º 4
0
        public void Should_ThrowPointValidationException_When_TheExistPointParametersAreInvalid(int locationX, int locationY)
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 5));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(locationX, locationY));
            _exitSetCommand.Set(_board, _exit);

            var exception = Assert.Throws <PointValidationException>(() => _exitSetCommand.Execute());

            Assert.Equal("Exit point is not valid!", exception.Message);
        }
Ejemplo n.º 5
0
        public void Should_ReturnTheGivenExitPoint_When_TheExistPointParametersAreValid()
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _exitSetCommand = new ExitSetCommand(new Point(3, 3));
            _exitSetCommand.Set(_board, _exit);
            _exitSetCommand.Execute();

            Assert.Equal(3, _exit.Point.X);
            Assert.Equal(3, _exit.Point.Y);
        }
Ejemplo n.º 6
0
        public void Should_ThrowPointValidationException_When_TurtlePointsAreInvalid(int locationX, int locationY)
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 5));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _turtleSetCommand = new TurtleSetCommand(new TurtlePoint(locationX, locationY, Direction.North));
            _turtleSetCommand.Set(_board, _turtle);

            var exception = Assert.Throws <PointValidationException>(() => _turtleSetCommand.Execute());

            Assert.Equal("Turtle point is not valid!", exception.Message);
        }
Ejemplo n.º 7
0
        public void Should_ThrowPointValidationException_When_TheInvalidMinePointsAreGiven(int locationX, int locationY)
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 5));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _mineSetCommand = new MineSetCommand(new Point(locationX, locationY));
            _mineSetCommand.Set(_board, _mine);

            var exception = Assert.Throws <PointValidationException>(() => _mineSetCommand.Execute());

            Assert.Equal("Mine point is not valid!", exception.Message);
        }
Ejemplo n.º 8
0
        public void Should_ReturnTheAvailableMinePoints_When_TheAppropriatePointsAreGiven()
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _mineSetCommand = new MineSetCommand(new Point(1, 2));
            _mineSetCommand.Set(_board, _mine);
            _mineSetCommand.Execute();

            Assert.Equal(1, _mine.Point.X);
            Assert.Equal(2, _mine.Point.Y);
        }
Ejemplo n.º 9
0
        public void Should_ReturnSpecifiedTurtlePointAndDirection_When_GivenParamtersAreValid()
        {
            _boardSetCommand = new BoardSetCommand(new Size(5, 4));
            _boardSetCommand.Set(_board);
            _boardSetCommand.Execute();

            _turtleSetCommand = new TurtleSetCommand(new TurtlePoint(1, 3, Direction.North));
            _turtleSetCommand.Set(_board, _turtle);
            _turtleSetCommand.Execute();

            Assert.Equal(1, _turtle.Point.X);
            Assert.Equal(3, _turtle.Point.Y);
            Assert.Equal(Direction.North, _turtle.Point.Direction);
        }