Example #1
0
    public void GeneratorThrowsExceptionWhenMapIsTooSmallForAllBombs(int bombsAmount, int width, int height)
    {
        BombGenerator bombGenerator = new BombGenerator();
        Map           map           = GenerateEmptyMap(width, height, bombsAmount);

        Exception ex = Assert.Throws <Exception>(() => bombGenerator.GenerateBombs(map));

        Assert.NotNull(ex);
    }
Example #2
0
    public void GeneratorGeneratesExaclyAsManyBombsAsRequested(int bombsAmount, int width, int height)
    {
        BombGenerator bombGenerator = new BombGenerator();
        Map           map           = GenerateEmptyMap(width, height, bombsAmount);

        Map generatedMap = bombGenerator.GenerateBombs(map);

        Assert.Equal(bombsAmount, HowManyBombsDoesMapHave(generatedMap));
    }
Example #3
0
    public void GeneratorDoesNotGenerateBombsWhichAreSurroundedByOtherBombs()
    {
        int           bombsAmount = 8, width = 3, height = 3;
        BombGenerator bombGenerator = new BombGenerator();
        Map           map           = GenerateEmptyMap(width, height, bombsAmount);

        for (int i = 0; i < 2; i++)
        {
            Map generatedMap = bombGenerator.GenerateBombs(map);
            Assert.False(IsAnyBombSurroundedByOtherBombs(generatedMap));
        }
    }