Beispiel #1
0
 public void Test_CellTable_Creation()
 {
     string text = "This    is   A     test  Of   The Cell Table method";
     CellTable cellTable = new CellTable(text);
     Assert.AreEqual(cellTable.NumItems, 9);
     var table = cellTable.GetTable();
     Assert.AreEqual(table[0, 0].Text, "This");
     Assert.AreEqual(table[0, 1].Value, (int)'i');
     Assert.AreEqual(table[0, 7].Value, (int)'t');
     Assert.AreEqual(table[0, 8].Text, "method");
 }
Beispiel #2
0
        public void Test_CellTable_GetLastPosition()
        {
            string text = "This    is   A     test  Of   The Cell Table method";
            CellTable cellTable = new CellTable(text);

            Position p = cellTable.GetLastPosition();
            Assert.AreEqual(p, new Position(0, 8));

            cellTable.Width = 3;
            p = cellTable.GetLastPosition();
            Assert.AreEqual(p, new Position(2, 2));
        }
Beispiel #3
0
        public void Test_CellTable_SetWidth()
        {
            string text = "This    is   A     test  Of   The Cell Table method";
            CellTable cellTable = new CellTable(text);

            for (int i = 1; i < cellTable.NumItems; i++)
            {
                cellTable.Width = i;
                var table = cellTable.GetTable();
                var p = cellTable.GetLastPosition();
                Assert.AreEqual(table.Length, i * cellTable.Height);
                Assert.AreEqual(table[p.x, p.y].Text, "method");
            }
        }
Beispiel #4
0
        public void Test_CellTable_GetShortextPath()
        {
            /// Testing GetShortestPath();
            var model = new CellTable("a z z b z z c d", 3);
            Assert.AreEqual(model.NumItems, 8);
            Assert.AreEqual(model.Width, 3);
            Assert.AreEqual(model.Height, 3);

            var path = model.GetShortestPath();
            var correct = new List<Position> {
                new Position(0,0), new Position(0,1),
                new Position(1,2)
            };
            Assert.IsTrue(path.Select(o => o.x).SequenceEqual(correct.Select(o => o.x)));
            Assert.IsTrue(path.Select(o => o.y).SequenceEqual(correct.Select(o => o.y)));
        }