예제 #1
0
        private IBoardRules CreateBoardWithMinesRules()
        {
            //Generate Mines
            var minesEverywhere = GenerateMines.GenerateMineLocation(64, 8, 8);

            return(new BoardMineSweeperRules(new Board(GenerateHorizontalArray.HorizontalChessArray(8), 8, minesEverywhere)));
        }
        public void BoardInstantiatedCorrectlyForXandY()
        {
            var boardToTest = new Board(GenerateHorizontalArray.HorizontalChessArray(4), 4, null);

            Assert.AreEqual(4, boardToTest.HorizontalArray.Length);
            Assert.AreEqual(4, boardToTest.VerticalAxis);
            Assert.AreEqual(0, boardToTest.NumberOfMines);
        }
        public void BoardRulesCheckForMinesThereAreNoMines()
        {
            //PositionToMoveto
            var positionToMoveTo = new Position(2, 2);

            var boardToTest = new Board(GenerateHorizontalArray.HorizontalChessArray(4), 4, null);
            var boardRules  = new BoardMineSweeperRules(boardToTest);

            Assert.IsFalse(boardRules.CheckForMines(positionToMoveTo));
        }
예제 #4
0
        public void HorizontalArrayGeneratedCorrectlyFor2()
        {
            var HorizontalArray = GenerateHorizontalArray.HorizontalChessArray(2);

            Assert.AreEqual("A", HorizontalArray[0]);

            Assert.AreEqual("B", HorizontalArray[1]);

            Assert.AreEqual(2, HorizontalArray.Length);
        }
        public void BoardRightReachedAndYouReachedTheEnd()
        {
            var boardToTest = new Board(GenerateHorizontalArray.HorizontalChessArray(4), 4, null);
            var boardRules  = new BoardMineSweeperRules(boardToTest);
            var results     = boardRules.ProcessRules(new Position(4, 2));

            Assert.AreEqual(true, results.ValidVertical);
            Assert.AreEqual(false, results.ValidHorizontal);
            Assert.AreEqual(true, results.ValidMove);
            Assert.AreEqual(true, results.ReachedTheEnd);

            Assert.AreEqual("Reached The End", results.Text);
        }
        public void BoardRulesCheckForMinesIHaveHitOneAndItGetsRemoved()
        {
            //PositionToMoveto
            var positionToMoveTo = new Position(4, 2);
            //Create a MineLocation at the same postion
            var minePositions = new List <IPosition> {
                positionToMoveTo
            };

            var boardToTest = new Board(GenerateHorizontalArray.HorizontalChessArray(4), 4, minePositions);
            var boardRules  = new BoardMineSweeperRules(boardToTest);

            Assert.IsTrue(boardRules.CheckForMines(positionToMoveTo));
            Assert.AreEqual(0, boardToTest.NumberOfMines);
        }
        public void BoardRulesCheckForMinesIHaveNotHitOne()
        {
            //PositionToMoveto
            var positionToMoveTo = new Position(4, 2);
            var minePosition     = new Position(1, 2);

            //Create a MineLocation at the same postion
            var minePositions = new List <IPosition> {
                minePosition
            };

            var boardToTest = new Board(GenerateHorizontalArray.HorizontalChessArray(4), 4, minePositions);
            var boardRules  = new BoardMineSweeperRules(boardToTest);

            Assert.IsFalse(boardRules.CheckForMines(positionToMoveTo));
        }
        public void BoardRulesIHaveHitAMineOnTheWinningEdge()
        {
            //PositionToMoveto
            var positionToMoveTo = new Position(4, 2);
            //Create a MineLocation at the same postion
            var minePositions = new List <IPosition> {
                positionToMoveTo
            };

            var boardToTest = new Board(GenerateHorizontalArray.HorizontalChessArray(4), 4, minePositions);
            var boardRules  = new BoardMineSweeperRules(boardToTest);
            var results     = boardRules.ProcessRules(positionToMoveTo);

            Assert.AreEqual(true, results.ValidVertical);
            Assert.AreEqual(false, results.ValidHorizontal);
            Assert.AreEqual(true, results.ValidMove);
            Assert.AreEqual(true, results.ReachedTheEnd);
            Assert.AreEqual(true, results.HitAMine);

            Assert.AreEqual("Reached The End", results.Text);
        }
예제 #9
0
 private IBoardRules CreateBoardRules()
 {
     return(new BoardMineSweeperRules(new Board(GenerateHorizontalArray.HorizontalChessArray(8), 8, null)));
 }
예제 #10
0
 public void HorizontalArrayGeneratedFailsForGreaterThan8()
 {
     Assert.Throws <ArgumentException>(() => GenerateHorizontalArray.HorizontalChessArray(9));
 }
예제 #11
0
 public void HorizontalArrayGeneratedFailsForLessThan1()
 {
     Assert.Throws <ArgumentException>(() => GenerateHorizontalArray.HorizontalChessArray(0));
 }