public void TestCascadeFlaggedCells()
        {
            int rows = 5;
            int cols = 5;

            var mines = new List<Point>
            {
                new Point(cols - 1, rows - 1)
            };
            IPointGenerator generator = new DeterminatePointGenerator(mines);
            IGameSettings settings = new GameSettings(rows, cols, mines.Count, generator);
            IMineSearchGame game = new MineSearchGame(settings);

            var flaggedPoint = new Point(1, 0);
            game.FlagCell(flaggedPoint);

            var revealedPoint = new Point(0, 0);
            game.RevealCell(revealedPoint);
            game.CascadeCell(revealedPoint);

            var revealedCells =
                game.Cells.Where(cell => cell.Revealed).Select(cell => cell.Coordinates).ToList();

            Assert.IsFalse(revealedCells.Contains(flaggedPoint));
        }
        public void TestSimple()
        {
            int rows = 5;
            int cols = 5;

            var mines = new List<Point>
            {
                new Point(0, 0)
            };
            IPointGenerator generator = new DeterminatePointGenerator(mines);
            IGameSettings settings = new GameSettings(rows, cols, mines.Count, generator);
            IMineSearchGame game = new MineSearchGame(settings);

            var point = new Point(cols - 1, rows - 1);
            game.RevealCell(point);
            game.CascadeCell(point);

            var revealedCells = game.Cells.Count(c => c.Revealed);
            Assert.AreEqual(game.Cells.Size - 1, revealedCells);
        }
        public void TestCascade()
        {
            var mine = new List<Point>
            {
                new Point(0, 2),
                new Point(3, 2),
                new Point(4, 2),
                new Point(0, 3),
                new Point(4, 4)
            };
            var pointGenerator = new DeterminatePointGenerator(mine);
            IGameSettings gameSettings = new GameSettings(5, 5, 5, pointGenerator);
            IMineSearchGame game = new MineSearchGame(gameSettings);

            var point = new Point(0, 0);
            game.RevealCell(point);
            game.CascadeCell(point);

            var revealedSafeCells = game.Cells.Where(cell => cell is SafeCell && cell.Revealed);

            Assert.AreEqual(10, revealedSafeCells.Count());
        }
        public void TestCreateCellsMinePlacement()
        {
            // Create the list of mine cells that will be fed to the generator.
            IList<Point> desiredCoords = new List<Point>
            {
                new Point(0, 2),
                new Point(1, 2),
                new Point(2, 1),
                new Point(2, 2)
            };
            IPointGenerator generator = new DeterminatePointGenerator(desiredCoords);

            // Create some simple game settings.
            IGameSettings gameSettings = new GameSettings(3, 3, 4, generator);
            var cellFactory = new MineSearchCellsFactory(gameSettings);
            // Create the cells via factory method.
            IMatrix<ICell> cells = cellFactory.CreateCells();

            // Ensure that the mine cells were placed where we wanted.
            var actualCoords =
                cells.Where(cell => cell is MineCell).Select(cell => cell.Coordinates);
            Assert.IsTrue(desiredCoords.ContainsAll(actualCoords));
        }