Esempio n. 1
0
    public void FiveByFiveTerritoryForBlack()
    {
        var board  = new GoCounting(boardFiveByFive);
        var result = board.TerritoryFor(new Point(0, 1));

        Assert.That(result.Item1, Is.EqualTo(GoCounting.Player.Black));
        Assert.That(result.Item2, Is.EquivalentTo(new[] { new Point(0, 0), new Point(0, 1), new Point(1, 0) }));
    }
Esempio n. 2
0
    public void FiveByFiveTerritoryForWhite()
    {
        var board  = new GoCounting(boardFiveByFive);
        var result = board.TerritoryFor(new Point(2, 3));

        Assert.That(result.Item1, Is.EqualTo(GoCounting.Player.White));
        Assert.That(result.Item2, Is.EquivalentTo(new[] { new Point(2, 3) }));
    }
Esempio n. 3
0
    public void FiveByFiveOpenTerritory()
    {
        var board  = new GoCounting(boardFiveByFive);
        var result = board.TerritoryFor(new Point(1, 4));

        Assert.That(result.Item1, Is.EqualTo(GoCounting.Player.None));
        Assert.That(result.Item2, Is.EquivalentTo(new[] { new Point(0, 3), new Point(0, 4), new Point(1, 4) }));
    }
Esempio n. 4
0
    public void MinimalBoardWithNoTerritories()
    {
        var input = "B";
        var board = new GoCounting(input);

        var expected = new Dictionary <GoPlayer, IEnumerable <Tuple <int, int> > >();

        Assert.Equal(expected, board.Territories());
    }
Esempio n. 5
0
    public void MinimalBoardWithNoTerritories()
    {
        var input = "B";
        var board = new GoCounting(input);

        var expected = new Dictionary <GoCounting.Player, IEnumerable <Point> >();

        Assert.That(board.Territories(), Is.EquivalentTo(expected));
    }
Esempio n. 6
0
    public void FiveByFiveOpenTerritory()
    {
        var board    = new GoCounting(boardFiveByFive);
        var result   = board.TerritoryFor(new Tuple <int, int>(1, 4));
        var expected = new HashSet <Tuple <int, int> > {
            new Tuple <int, int>(0, 3), new Tuple <int, int>(0, 4), new Tuple <int, int>(1, 4)
        };

        Assert.Equal(GoPlayer.None, result.Item1);
        Assert.True(expected.SetEquals(result.Item2));
    }
Esempio n. 7
0
    public void FiveByFiveTerritoryForWhite()
    {
        var board    = new GoCounting(boardFiveByFive);
        var result   = board.TerritoryFor(new Tuple <int, int>(2, 3));
        var expected = new HashSet <Tuple <int, int> > {
            new Tuple <int, int>(2, 3)
        };

        Assert.Equal(GoPlayer.White, result.Item1);
        Assert.True(expected.SetEquals(result.Item2));
    }
Esempio n. 8
0
    public void FiveByFiveTerritoryForBlack()
    {
        var board    = new GoCounting(boardFiveByFive);
        var result   = board.TerritoryFor(new Tuple <int, int>(0, 1));
        var expected = new HashSet <Tuple <int, int> > {
            new Tuple <int, int>(0, 0), new Tuple <int, int>(0, 1), new Tuple <int, int>(1, 0)
        };

        Assert.Equal(GoPlayer.Black, result.Item1);
        Assert.True(expected.SetEquals(result.Item2));
    }
Esempio n. 9
0
    public void OneTerritoryCoveringTheWholeBoard()
    {
        var input = " ";
        var board = new GoCounting(input);

        var expected = new Dictionary <GoCounting.Player, IEnumerable <Point> >
        {
            [GoCounting.Player.None] = new[] { new Point(0, 0) }
        };

        Assert.That(board.Territories(), Is.EquivalentTo(expected));
    }
Esempio n. 10
0
 public void Black_corner_territory_on_5x5_board()
 {
     var coordinate = (0, 1);
     var board = 
         "  B  \n" +
         " B B \n" +
         "B W B\n" +
         " W W \n" +
         "  W  ";
     var sut = new GoCounting(board);
     var actual = sut.Territory(coordinate);
     var expected = (Owner.Black, new[] { (0, 0), (0, 1), (1, 0) });
Esempio n. 11
0
    public void TwoTerritoriesOnRectangularBoard()
    {
        var input = string.Join("\n", new[] { " BW ", " BW " });
        var board = new GoCounting(input);

        var expected = new Dictionary <GoCounting.Player, IEnumerable <Point> >
        {
            [GoCounting.Player.Black] = new[] { new Point(0, 0), new Point(0, 1) },
            [GoCounting.Player.White] = new[] { new Point(3, 0), new Point(3, 1) }
        };

        Assert.That(board.Territories(), Is.EquivalentTo(expected));
    }
Esempio n. 12
0
    public void OneTerritoryCoveringTheWholeBoard()
    {
        var input  = " ";
        var board  = new GoCounting(input);
        var actual = board.Territories();

        var expected = new Dictionary <GoPlayer, IEnumerable <Tuple <int, int> > >
        {
            [GoPlayer.None] = new[] { new Tuple <int, int>(0, 0) }
        };

        Assert.Equal(expected.Keys, actual.Keys);
        Assert.Equal(expected[GoPlayer.None], actual[GoPlayer.None]);
    }
Esempio n. 13
0
    public void TwoTerritoriesOnRectangularBoard()
    {
        var input  = string.Join("\n", new[] { " BW ", " BW " });
        var board  = new GoCounting(input);
        var actual = board.Territories();

        var expected = new Dictionary <GoPlayer, IEnumerable <Tuple <int, int> > >
        {
            [GoPlayer.Black] = new[] { new Tuple <int, int>(0, 0), new Tuple <int, int>(0, 1) },
            [GoPlayer.White] = new[] { new Tuple <int, int>(3, 0), new Tuple <int, int>(3, 1) }
        };

        Assert.Equal(expected.Keys, actual.Keys);
        Assert.Equal(expected[GoPlayer.Black], actual[GoPlayer.Black]);
        Assert.Equal(expected[GoPlayer.White], actual[GoPlayer.White]);
    }
Esempio n. 14
0
    public void FiveByFiveNonTerritoryStone()
    {
        var board = new GoCounting(boardFiveByFive);

        Assert.Null(board.TerritoryFor(new Tuple <int, int>(1, 1)));
    }
Esempio n. 15
0
    public void FiveByFiveNonTerritoryDueToTooHighCoordinate()
    {
        var board = new GoCounting(boardFiveByFive);

        Assert.That(board.TerritoryFor(new Point(1, 5)), Is.Null);
    }
Esempio n. 16
0
    public void FiveByFiveNonTerritoryStone()
    {
        var board = new GoCounting(boardFiveByFive);

        Assert.That(board.TerritoryFor(new Point(1, 1)), Is.Null);
    }
Esempio n. 17
0
    public void FiveByFiveNonTerritoryDueToTooHighCoordinate()
    {
        var board = new GoCounting(boardFiveByFive);

        Assert.Null(board.TerritoryFor(new Tuple <int, int>(1, 5)));
    }