public void TestToStringAllFieldsRevealed5() { int rows = 5; int columns = 10; Field[,] fixedFields = new Field[rows, columns]; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { fixedFields[i, j] = new Field(); } } Board board = new Board(rows, columns, 10); Type type = typeof(Board); var fieldValue = type.GetField("fields", BindingFlags.Instance | BindingFlags.NonPublic); fieldValue.SetValue(board, fixedFields); StringBuilder str = new StringBuilder(); str.Append(" 0 1 2 3 4 5 6 7 8 9 \n"); str.Append(" _____________________\n"); str.Append("0 | 0 0 0 0 0 0 0 0 0 0 |\n"); str.Append("1 | 0 0 0 0 0 0 0 0 0 0 |\n"); str.Append("2 | 0 0 0 0 0 0 0 0 0 0 |\n"); str.Append("3 | 0 0 0 0 0 0 0 0 0 0 |\n"); str.Append("4 | 0 0 0 0 0 0 0 0 0 0 |\n"); str.Append(" _____________________\n"); string expected = str.ToString(); string actual = board.ToStringAllFieldsRevealed(); Assert.AreEqual( expected, actual, string.Format("The board string is {0}, but must be {1}!", actual, expected)); }
public void TestToStringAllFieldsRevealed1() { Board board = new Board(2, 2, 4); StringBuilder result = new StringBuilder(); result.Append(" 0 1 \n"); result.Append(" _____\n"); result.Append("0 | * * |\n"); result.Append("1 | * * |\n"); result.Append(" _____\n"); string expected = result.ToString(); string actual = board.ToStringAllFieldsRevealed(); Assert.AreEqual(expected, actual, "Wrong count of opened fields!"); }