public void CannotAddSamePieceTwice(int[] dimensions, int[] location)
        {
            var gameBoard = new GameBoard2d(dimensions, 4);

            var piece = new GamePiece(-1, "Test", new NoMovementStrategy(), true);

            gameBoard.PlacePiece(piece, location);

            Assert.ThrowsException <ArgumentException>(() => gameBoard.PlacePiece(piece, location));
        }
        public void CheckAddingFetchingAndMovingAPiece(int[] dimensions, int[] location, int[] destination)
        {
            var gameBoard = new GameBoard2d(dimensions, 4);

            var piece = new GamePiece(-1, "Test", new NoMovementStrategy(), true);

            gameBoard.PlacePiece(piece, location);

            var resultingPieces = gameBoard.GetPiecesInLocation(location);

            Assert.IsNotNull(resultingPieces);

            Assert.AreEqual(1, resultingPieces.Count());

            Assert.IsNotNull(resultingPieces.FirstOrDefault());

            gameBoard.MovePiece(piece, destination);

            resultingPieces = gameBoard.GetPiecesInLocation(location);

            Assert.IsNotNull(resultingPieces);

            Assert.AreEqual(0, resultingPieces.Count());

            resultingPieces = gameBoard.GetPiecesInLocation(destination);

            Assert.IsNotNull(resultingPieces);

            Assert.AreEqual(1, resultingPieces.Count());

            Assert.IsNotNull(resultingPieces.FirstOrDefault());
        }
        public void CheckAddingAPiece(int[] dimensions, int[] location)
        {
            var gameBoard = new GameBoard2d(dimensions, 4);

            var piece = new GamePiece(-1, "Test", new NoMovementStrategy(), true);

            gameBoard.PlacePiece(piece, location);
        }
        public void CheckAddingAPieceOutsideTheBoardIsHandled(int[] dimensions, int[] location)
        {
            var gameBoard = new GameBoard2d(dimensions, 4);

            var piece = new GamePiece(-1, "Test", new NoMovementStrategy(), true);

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => gameBoard.PlacePiece(piece, location));
        }
        public void GetPiecesInLocation(int[] dimensions, int[] location)
        {
            var gameBoard = new GameBoard2d(dimensions, 4);

            var piece = new GamePiece(-1, "Test", new NoMovementStrategy(), true);

            gameBoard.PlacePiece(piece, location);

            var pieces = gameBoard.GetPiecesInLocation(location);

            Assert.AreSame(piece, pieces.FirstOrDefault());
        }
        public void GetPiecesLocation(int[] dimensions, int[] location)
        {
            var gameBoard = new GameBoard2d(dimensions, 4);

            var piece = new GamePiece(-1, "Test", new NoMovementStrategy(), true);

            gameBoard.PlacePiece(piece, location);

            var piecesLocation = gameBoard.GetPiecesLocation(piece);

            Assert.AreEqual(location[0], piecesLocation.ElementAt(0));
            Assert.AreEqual(location[1], piecesLocation.ElementAt(1));
        }
        public void CheckMultipleAddingAndFetching3SidedPiece(int[] dimensions, int[] location, int noOfPieces)
        {
            var gameBoard = new GameBoard2d(dimensions, 3);

            var pieces = new List <IGamePiece>();

            for (var i = 0; i < noOfPieces; i++)
            {
                var piece = new GamePiece(-1, "Test", new NoMovementStrategy(), true);

                gameBoard.PlacePiece(piece, location);
            }

            var resultingPieces = gameBoard.GetPiecesInLocation(location);

            Assert.IsNotNull(resultingPieces);

            Assert.AreEqual(noOfPieces, resultingPieces.Count());
        }
        public void GetAdjacentPieces(int[] dimensions, int[] location, int expected)
        {
            var gameBoard = new GameBoard2d(dimensions, 4);

            int x, y;

            x = dimensions[0];
            y = dimensions[1];

            for (var i = 0; i < x; i++)
            {
                for (var j = 0; j < y; j++)
                {
                    gameBoard.PlacePiece(new GamePiece(-1, "Test", new NoMovementStrategy(), true), new[] { i, j });
                }
            }

            var piece = gameBoard.GetPiecesInLocation(location).FirstOrDefault();

            var adjacentLocations = gameBoard.GetAdjacentPieces(piece);

            Assert.AreEqual(expected, adjacentLocations.Count());
        }