public void TestBoardStringToPieces() { Game.Board b = new Game.Board(); b.BoardString = b.Initialize8x8Board(); b.BoardStringToPieces(); Assert.IsTrue(b.Pieces != null); Assert.IsTrue(b.Pieces.Count == 32); }
public void TestValidPawnMovesForward_init() { Game.Board b = new Game.Board(); b.BoardString = b.Initialize8x8Board(); b.BoardStringToPieces(); // initial board returns a valid set of two moves Game.Piece p = Game.GetPieceOnSquare(b, '1', '2'); Assert.IsTrue(p != null); List <Point> pts2 = Game.ValidMoves(b, p); Assert.IsTrue(pts2.Count > 0); Assert.IsTrue(pts2.Count == 2); Assert.IsTrue(pts2[0].X == 1); // first move coordinates Assert.IsTrue(pts2[0].Y == 3); Assert.IsTrue(pts2[1].X == 1); // second move coordinates Assert.IsTrue(pts2[1].Y == 4); }
public void Test_GetPiecesOnSquare_InitialBoard() { Game.Board b = new Game.Board(); b.BoardString = b.Initialize8x8Board(); b.BoardStringToPieces(); Assert.IsTrue(b.Pieces != null); Assert.IsTrue(b.Pieces.Count == 32); // iterate over the board // first row string FirstRow = "RNBKQBNR"; for (int i = 1; i < 8; i++) { Game.Piece p = Game.GetPieceOnSquare(b, i.ToString()[0], '1'); Assert.IsTrue(p != null); Assert.IsTrue(p.color == "w"); Assert.IsTrue(p.type == FirstRow[i - 1].ToString()); } // second row // (all pawns) for (int i = 1; i < 8; i++) { Game.Piece p = Game.GetPieceOnSquare(b, i.ToString()[0], '2'); Assert.IsTrue(p != null); Assert.IsTrue(p.color == "w"); Assert.IsTrue(p.type == 'P'.ToString()); } // third - sixth rows have no pieces on start for (int j = 3; j < 7; j++) { for (int i = 1; i < 8; i++) { Game.Piece p = Game.GetPieceOnSquare(b, i.ToString()[0], j.ToString()[0]); Assert.IsTrue(p == null); } } // seventh row for (int i = 1; i < 8; i++) { Game.Piece p = Game.GetPieceOnSquare(b, i.ToString()[0], '7'); Assert.IsTrue(p != null); Assert.IsTrue(p.color == "b"); Assert.IsTrue(p.type == 'p'.ToString()); } // eighth row string EighthRow = "rnbkqbnr"; for (int i = 1; i < 8; i++) { Game.Piece p = Game.GetPieceOnSquare(b, i.ToString()[0], '8'); Assert.IsTrue(p != null); Assert.IsTrue(p.color == "b"); Assert.IsTrue(p.type == EighthRow[i - 1].ToString()); } }