示例#1
0
        public void RevealEmptyCellAroundIfOpenEmptyCell()
        {
            var game = MineField.Build(3, new List <ICell>()
            {
                new UndiscoveredCell(0, 0),
                new UndiscoveredCell(0, 1),
                new UndiscoveredCell(0, 2),
                new UndiscoveredCell(1, 0),
                new UndiscoveredCell(1, 1),
                new UndiscoveredCell(1, 2),
                new UndiscoveredCell(2, 0),
                new UndiscoveredCell(2, 1),
                new UndiscoveredCell(2, 2),
            });

            game.Reveal(1, 1);
            game.Should().AllBeAssignableTo <EmptyCell>();
        }
示例#2
0
        public void RevealNumberCellAroundIfOpenEmptyCellNearBomb()
        {
            var game = MineField.Build(3, new List <ICell>()
            {
                new UndiscoveredCell(0, 0)
                {
                    HasBomb = true
                },
                new UndiscoveredCell(0, 1)
                {
                    NumberOfBombsAround = 1
                },
                new UndiscoveredCell(0, 2),
                new UndiscoveredCell(1, 0)
                {
                    NumberOfBombsAround = 1
                },
                new UndiscoveredCell(1, 1)
                {
                    NumberOfBombsAround = 1
                },
                new UndiscoveredCell(1, 2),
                new UndiscoveredCell(2, 0),
                new UndiscoveredCell(2, 1),
                new UndiscoveredCell(2, 2),
            });

            game.Reveal(1, 0);

            game[0, 0].Should().BeAssignableTo <UndiscoveredCell>();
            game[0, 1].Should().BeAssignableTo <NumberCell>();
            game[0, 2].Should().BeAssignableTo <UndiscoveredCell>();
            game[1, 0].Should().BeAssignableTo <EmptyCell>();
            game[1, 1].Should().BeAssignableTo <NumberCell>();
            game[1, 2].Should().BeAssignableTo <UndiscoveredCell>();
            game[2, 0].Should().BeAssignableTo <EmptyCell>();
            game[2, 1].Should().BeAssignableTo <EmptyCell>();
            game[2, 2].Should().BeAssignableTo <UndiscoveredCell>();
        }