Beispiel #1
0
        public void TextGrid_FillChar()
        {
            var grid = new TextGrid();

            grid.SetCellFormat(0, 0, new TextGridFormat('-'));
            grid[0, 0] = "";
            grid[0, 1] = "abcd";
            Assert.AreEqual("----\r\nabcd\r\n", grid.ToString());

            grid.Clear();
            grid.SetCellFormat(0, 1, new TextGridFormat('-'));
            grid[0, 0] = "abcd";
            grid[0, 1] = "efghijklmno";
            Assert.AreEqual("abcd\r\n----\r\n", grid.ToString());
        }
Beispiel #2
0
        public void TextGrid_ColumnFormats()
        {
            var grid = new TextGrid();

            grid.NAString = "null";
            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 5));
            grid.SetColumnFormat(1, new TextGridFormat(TextGridAlign.Default, 10));
            grid[0, 0] = null;
            grid[1, 0] = null;
            grid[2, 0] = "foo";
            Assert.AreEqual("null  null       foo\r\n", grid.ToString());

            grid          = new TextGrid();
            grid.NAString = "null";
            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 5));
            grid[0, 0] = "a";
            grid[0, 1] = "ab";
            grid[0, 2] = "abc";
            grid[0, 3] = "abcd";
            grid[0, 4] = "abcde";
            grid[0, 5] = "abcdef";
            Assert.AreEqual("a    \r\nab   \r\nabc  \r\nabcd \r\nabcde\r\nab...\r\n", grid.ToString());

            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 0));
            Assert.AreEqual("\r\n\r\n\r\n\r\n\r\n\r\n", grid.ToString());

            grid.ClearCells();
            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 1));
            grid[0, 0] = "a";
            Assert.AreEqual("a\r\n", grid.ToString());
            grid[0, 0] = "ab";
            Assert.AreEqual(".\r\n", grid.ToString());

            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 2));
            Assert.AreEqual("ab\r\n", grid.ToString());
            grid[0, 0] = "abc";
            Assert.AreEqual("..\r\n", grid.ToString());

            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 3));
            Assert.AreEqual("abc\r\n", grid.ToString());
            grid[0, 0] = "abcd";
            Assert.AreEqual("...\r\n", grid.ToString());

            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 4));
            Assert.AreEqual("abcd\r\n", grid.ToString());
            grid[0, 0] = "abcde";
            Assert.AreEqual("a...\r\n", grid.ToString());

            grid.Clear();
            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Left, -1));
            grid[0, 0] = "ab";
            grid[0, 1] = "a";
            Assert.AreEqual("ab\r\na \r\n", grid.ToString());

            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Right, -1));
            Assert.AreEqual("ab\r\n a\r\n", grid.ToString());

            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Left, 4));
            grid[0, 0] = "ab";
            grid[0, 1] = "a";
            Assert.AreEqual("ab  \r\na   \r\n", grid.ToString());

            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Center, 4));
            Assert.AreEqual(" ab \r\n a  \r\n", grid.ToString());

            grid.Clear();
            grid.NAString = "";
            grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Center, 4));
            grid[1, 0] = "foo";
            Assert.AreEqual("     foo\r\n", grid.ToString());
        }