Пример #1
0
        public void BorderSquaresOn8x8Board(int n, int?nw, int?ne, int?se, int?sw)
        {
            var board  = BoardPosition.InitialSetup(8);
            var square = board[new SquareId(n)];

            Square?result;

            square.TryGetBorder(Direction.NW, out result).Should().Be(nw is not null);
            result?.Id.Value.Should().Be(nw);

            square.TryGetBorder(Direction.NE, out result).Should().Be(ne is not null);
            result?.Id.Value.Should().Be(ne);

            square.TryGetBorder(Direction.SE, out result).Should().Be(se is not null);
            result?.Id.Value.Should().Be(se);

            square.TryGetBorder(Direction.SW, out result).Should().Be(sw is not null);
            result?.Id.Value.Should().Be(sw);
        }
        public void InitialBoard4x4()
        {
            // |_|4|_|4|
            // |.|_|.|_|
            // |_|.|_|.|
            // |5|_|5|_|
            var board = BoardPosition.InitialSetup(4);

            board.Size.Should().Be(4);

            for (int y = 0; y < board.Size; y++)
            {
                for (int x = 0; x < board.Size; x++)
                {
                    if (y == 0 && (x == 1 || x == 3))
                    {
                        board[x, y] !.Piece.Should().Be(Piece.BlackMan);
                    }
                    else if (y == 3 && (x == 0 || x == 2))
                    {
                        board[x, y] !.Piece.Should().Be(Piece.WhiteMan);
                    }
                    else if (BoardPosition.IsPlayable(x, y))
                    {
                        board[x, y] !.Piece.Should().Be(Piece.Empty, $"because we're at ({x}, {y})");
                    }
                    else
                    {
                        board[x, y].Should().BeNull($"because we're at ({x}, {y})");
                    }
                }
            }

            board.NrOfPiecesPerColor(Color.Black).Should().Be(2);
            board.NrOfPiecesPerColor(Color.White).Should().Be(2);
        }
 public void LongStringToBoard()
 {
     BoardPosition.FromString(" 4 4,0 0 , 0 0,5 5 ", ",").Should().Be(BoardPosition.InitialSetup(4));
 }
 public void StringToBoard()
 {
     BoardPosition.FromString("44000055").Should().Be(BoardPosition.InitialSetup(4));
 }
 public void BoardToLongString()
 {
     BoardPosition.InitialSetup(4).ToLongString(",").Should().Be(" 4 4,0 0 , 0 0,5 5 ");
 }
 public void BoardToString()
 {
     BoardPosition.InitialSetup(4).ToString().Should().Be("44000055");
 }
        public void InitialBoard10x10()
        {
            var board = BoardPosition.InitialSetup(10);

            board.Should().Be(BoardPosition.FromString("44444,44444,44444,44444,00000,00000,55555,55555,55555,55555", ","));
        }