Example #1
0
        public void UsingFunctionPlaceMineShouldReturnStar()
        {
            var cell = new Cell();

            var result = cell.placeMine();

            Assert.AreEqual("*", result);
        }
Example #2
0
        public void UsingFunctionPlaceEmptyCellShouldReturn0()
        {
            var cell = new Cell();

            var result = cell.placeEmptyCell();

            Assert.AreEqual(0, result);
        }
Example #3
0
        public BigField()
        {
            for (byte i = 0; i < Size; i++)
            {
                for (byte a = 0; a < Size; a++)
                {
                    BigFieldArray[i, a] = new Cell();
                }
            }

            HasShip();
        }
Example #4
0
        public void EmptyCellShouldReturnTrueAndMineCellShouldReturnFalse()
        {
            var cell = new Cell();

            cell.placeEmptyCell();
            var resultEmptyCell = cell.CurrentState;

            cell.placeMine();
            var resultMineCell = cell.CurrentState;

            Assert.AreEqual(false, resultEmptyCell);
            Assert.AreEqual(true, resultMineCell);
        }
Example #5
0
        private void Initialization(int sizeX, int sizeY, int amountMines)
        {
            this.height = sizeY;
            this.width = sizeX;
            this.mines = amountMines;

            if (height == 0 || width == 0)
                throw new System.ArgumentException("Size of dimensions of board should be different than \"0\"", "height, width");

            if (width * height <= mines)
                throw new System.ArgumentException("Amount of mines should be lower than the numbers of cells", "mines");

            this.cellTable = new Cell[width, height];

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    cellTable[i, j] = new Cell();
                    cellTable[i, j].placeEmptyCell();
                }
            }
        }