public void InitEnumerator() { FieldCellFactory testFactory = new FieldCellFactory(8, 8, '&', ConsoleColor.Blue, ConsoleColor.Red); Table testTable = new Table(testFactory, new Frame("../../test.txt")); tableEnumerator = new TableEnumerator(testTable); }
public void TraverseAndTinitializeCorrectlyWhenCorrectDataIsProvided() { string expectedFrameImage = "This\nIs some text,\nMent to test the\nframe\n"; FieldCellFactory testFactory = new FieldCellFactory(8, 8, '&', ConsoleColor.Blue, ConsoleColor.Red); Table testTable = new Table(testFactory, new Frame("../../test.txt")); bool testISValid = true; bool isCurrentOdd; string expectedCell = ""; string givenCell = ""; for (int i = 0; i < 8; i++) { isCurrentOdd = (i % 2 == 0); for (int j = 0; j < 8; j++) { expectedCell = j + " " + i + " & " + (isCurrentOdd? ConsoleColor.Red : ConsoleColor.Blue); isCurrentOdd = !isCurrentOdd; givenCell = testTable.Cells[j, i].Row + " " + testTable.Cells[j, i].Col + " " + testTable.Cells[j, i].Value + " " + testTable.Cells[j, i].Color; if (expectedCell != givenCell) { testISValid = false; break; } } if (!testISValid) { break; } } Console.WriteLine( ); Assert.IsTrue(testISValid, "One of the cells wasn't initialized or returned properly.\nExpected:" + expectedCell + "\nGiven:\n" + givenCell); Assert.AreEqual(testTable.Frame.Image, expectedFrameImage, "The frame image isn't the expected one.\nImageGiven by the table:\n" + testTable.Frame.Image + "\nExpected Image:\n" + expectedFrameImage); }
public void TheIteratorShouldIterateOverTheTableProperly() { FieldCellFactory testFactory = new FieldCellFactory(8, 8, '&', ConsoleColor.Blue, ConsoleColor.Red); Table testTable = new Table(testFactory, new Frame("../../test.txt")); ICell result; int row = 0; int col = 0; foreach (ICell item in testTable) { result = item; Assert.AreEqual(row, result.Row, "The row is not correc. Expected value: " + row + " Actual value: " + result.Row); Assert.AreEqual(col, result.Col, "The col is not correc. Expected value: " + col + " Actual value: " + result.Col); row++; if (row == testTable.Cells.GetLength(0)) { row = 0; col++; } } }