Exemplo n.º 1
0
        public void ScanningWhenTwoBombsAreAround()
        {
            var board        = new Board(4, 4, 1);
            var boardScanner = new BoardScanner(board);
            var bombSetter   = new MineSetter(new RandomGeneratorForTesting(3));
            var bombSetter2  = new MineSetter(new RandomGeneratorForTesting(2));

            board.Accept(bombSetter);
            board.Accept(bombSetter2);
            int expected = 2;
            int actual   = boardScanner.ScanSurroundingFields(2, 3);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void SettingBombOnSpecificRowAndColTest()
        {
            var board      = new Board(4, 4, 1);
            var bombSetter = new MineSetter(new RandomGeneratorForTesting(1));

            board.Accept(bombSetter);
            var fieldMatrix   = board.FieldsMatrix;
            var fieldWithBomb = board.FieldsMatrix[1, 1];

            Assert.AreEqual(fieldWithBomb, new Field(0, FieldStatus.IsAMine));
        }
Exemplo n.º 3
0
        public void TestMineSetter()
        {
            var board       = new Board(5, 5, 10);
            var fieldMatrix = board.FieldsMatrix;
            var bombSetter  = new MineSetter(new RandomGenerator());

            board.Accept(bombSetter);
            bool allFieldsAreClosed = AreAllFieldsClosed(fieldMatrix);

            Assert.IsFalse(allFieldsAreClosed);
        }
Exemplo n.º 4
0
        public void OpenFieldSuccessfullyTest()
        {
            var board        = new Board(4, 4, 1);
            var boardScanner = new BoardScanner(board);
            var boardManager = new BoardManager(board, boardScanner);

            var bombSetter = new MineSetter(new RandomGeneratorForTesting(2));

            board.Accept(bombSetter);
            var openedField = boardManager.OpenField(2, 1);

            Assert.AreEqual(openedField, BoardStatus.SuccessfullyOpened);
        }
Exemplo n.º 5
0
        public void OpenFieldWithBombTest()
        {
            var board        = new Board(4, 4, 1);
            var boardScanner = new BoardScanner(board);
            var boardManager = new BoardManager(board, boardScanner);

            var bombSetter = new MineSetter(new RandomGeneratorForTesting(1));

            board.Accept(bombSetter);
            var openedField = boardManager.OpenField(1, 1);

            Assert.AreEqual(openedField, BoardStatus.SteppedOnAMine);
        }
Exemplo n.º 6
0
        public void OpenFieldWhichIsAlreadyOpened()
        {
            var board        = new Board(4, 4, 1);
            var boardScanner = new BoardScanner(board);
            var boardManager = new BoardManager(board, boardScanner);

            var bombSetter = new MineSetter(new RandomGeneratorForTesting(2));

            board.Accept(bombSetter);
            var openedField        = boardManager.OpenField(2, 1);
            var secondOpeningField = boardManager.OpenField(2, 1);

            Assert.AreEqual(secondOpeningField, BoardStatus.AlreadyOpened);
        }
Exemplo n.º 7
0
        public void ScanningForMinesTest()
        {
            var board        = new Board(4, 4, 1);
            var boardScanner = new BoardScanner(board);
            var bombSetter   = new MineSetter(new RandomGeneratorForTesting(3));

            board.Accept(bombSetter);
            var fieldWithBomb = board.FieldsMatrix[3, 3];

            Assert.AreEqual(fieldWithBomb, new Field(0, FieldStatus.IsAMine));
            var adjacentField = board.FieldsMatrix[2, 3];
            int minesAround   = boardScanner.ScanSurroundingFields(2, 3);

            Assert.AreEqual(1, minesAround);
        }