Ejemplo n.º 1
0
        public void TestForceLower()
        {
            var documentWidth = 5;
            var cellWidth     = 5;
            var initialValue  = "Abc";
            var expectedValue = "abc  ";

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();
            var cell     = row.WriteText(initialValue, cellWidth, RawTextFlags.ForceLower);

            var actualValue = cell.GetValue().GetFullValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 2
0
        public void TestCenterAlignmentOverMaxLimit()
        {
            var documentWidth = 10;
            var cellWidth     = 10;
            var initialValue  = "ABCDEFGHIJKL";
            var expectedValue = "ABCDEFGHIJ";

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();
            var cell     = row.WriteText(initialValue, cellWidth, RawTextFlags.Center);

            var actualValue = cell.GetValue().GetFullValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 3
0
        public void TestRepeatingText()
        {
            var documentWidth = 5;
            var cellWidth     = 5;
            var initialValue  = "Abc";
            var expectedValue = "AbcAb";

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();
            var cell     = row.WriteRepeatingText(initialValue, cellWidth);

            var actualValue = cell.GetValue().GetFullValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 4
0
        public void TestRightAlignmentEqualMaxLimitMinus1()
        {
            var documentWidth = 10;
            var cellWidth     = 10;
            var initialValue  = "ABCDEFGHI";
            var expectedValue = " ABCDEFGHI";

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();
            var cell     = row.WriteText(initialValue, cellWidth, RawTextFlags.Right);

            var actualValue = cell.GetValue().GetFullValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
        public void TestOneCellAtMaxWidth()
        {
            var documentWidth = 10;
            var cell1Value    = "ABC";
            var expectedValue = "ABC       ";

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();

            row.WriteText(cell1Value, 10, RawTextFlags.Left);

            var actualValue = row.GetValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
        public void TestOneCellUnderMaxWidthBold()
        {
            var documentWidth = 10;
            var cell1Value    = "ABC";
            var expectedValue = PrinterCode.BoldOn + "ABC       " + PrinterCode.BoldOff;

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();
            var cell     = row.WriteText(cell1Value, 5, RawTextFlags.Left);

            cell.Bold = true;

            var actualValue = row.GetValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 7
0
        public void TestUnderline()
        {
            var documentWidth = 5;
            var cellWidth     = 5;
            var initialValue  = "Abc";
            var expectedValue = PrinterCode.UnderlineOn + "Abc  " + PrinterCode.UnderlineOff;

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();
            var cell     = row.WriteText(initialValue, cellWidth);

            cell.Underline = true;

            var actualValue = cell.GetValue().GetFullValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
        public void TestOneRowTwoCellsWithTrimAndNewLine()
        {
            var documentWidth = 10;
            var cellValue     = "ABC";
            var expectedValue = "ABC  ABC\r\n";

            var document = new RawTextDocument(documentWidth);
            var row      = document.CreateNewRow();
            var cell1    = row.WriteText(5, RawTextFlags.Left);

            cell1.Value = cellValue;
            var cell2 = row.WriteText(5, RawTextFlags.Left);

            cell2.Value = cellValue;

            var actualValue = document.GetDocumentValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
        public void TestTwoRowsTwoCellsWithCustomNewLine()
        {
            var documentWidth = 10;
            var cellValue     = "ABC";
            var expectedValue = "ABC  ABC  \nABC  ABC  \n";

            var document = new RawTextDocument(documentWidth);

            document.TrimEndOnRow = false;
            document.NewLineValue = "\n";

            for (var rowNumber = 1; rowNumber <= 2; rowNumber++)
            {
                var row   = document.CreateNewRow();
                var cell1 = row.WriteText(5, RawTextFlags.Left);
                cell1.Value = cellValue;
                var cell2 = row.WriteText(5, RawTextFlags.Left);
                cell2.Value = cellValue;
            }

            var actualValue = document.GetDocumentValue();

            Assert.AreEqual(expectedValue, actualValue);
        }
        public void SampleIndianaPoliceCardTest()
        {
            const int    leftColumnWidth            = 45;
            const string horizontalSeparatorValue   = "| ";
            const string verticalSeparatorValue     = "-";
            const string intersectingSeparatorValue = "+";
            const int    rightColumnWidth           = 32;
            var          document = new RawTextDocument(80);

            document.AddPrinterCode(PrinterCode.LineDensity8Dpi);
            document.AddPrinterCode(PrinterCode.HorizontalSpacing171Cpi);

            var row = document.CreateNewRow();

            row.WriteText("NAME OF CUSTOMER", leftColumnWidth);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("SERIAL NUMBER", rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText("Hammond, James R", leftColumnWidth, RawTextFlags.ForceUpper);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText(string.Empty, rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteRepeatingText(verticalSeparatorValue, 45);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 28);

            row = document.CreateNewRow();
            row.WriteText("CUSTOMER SIGNATURE", leftColumnWidth);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("ITEM", rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText(string.Empty, leftColumnWidth);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("NUG DROP", rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteRepeatingText(verticalSeparatorValue, 45);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 28);

            row = document.CreateNewRow();
            row.WriteText("ADDRESS", leftColumnWidth);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("DESIGN / MODEL / MAKE / CAL /", rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText("8025 W.RUSSELL RD #1125", leftColumnWidth);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("         SIZE / DESC.", rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteRepeatingText(verticalSeparatorValue, 27);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 10);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 6);
            row.WriteText(intersectingSeparatorValue);

            row = document.CreateNewRow();
            row.WriteText("CITY - STATE - ZIP", 27);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("DOB", 9);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("EYES", 5);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("NUG DROP;Y/G;14 KT.;APPRX 8.9 GRM;", rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText("LAS VEGAS, NV89113", 27);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("09/27/67", 9);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("GRN", 5);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("ORM SHAPED;", rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteRepeatingText(verticalSeparatorValue, 6);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 7);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 12);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 7);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 2);
            row.WriteText(intersectingSeparatorValue);
            row.WriteRepeatingText(verticalSeparatorValue, 6);
            row.WriteText(intersectingSeparatorValue);

            row = document.CreateNewRow();
            row.WriteText("SEX", 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("HEIGHT", 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("WEIGHT", 11);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("HAIR", 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("ORIGIN", 8);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText(string.Empty, rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText("M", 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("5'10", 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("215", 11, RawTextFlags.Right);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("BRN", 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("W", 8);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText(string.Empty, rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText("------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("-------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("------------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("-------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("---------");
            row.WriteText(intersectingSeparatorValue);

            row = document.CreateNewRow();
            row.WriteText("IDENTIFICATION TYPE DR LIC OR VALID PHOTO ID", leftColumnWidth);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText(string.Empty, rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText("DL-NV-2000407563", leftColumnWidth);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText(string.Empty, rightColumnWidth);

            row = document.CreateNewRow();
            row.WriteText("-------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("-------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("------------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("--");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("--------------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("--------------");

            row = document.CreateNewRow();
            row.WriteText("CONS", 7);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("TRADE", 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("PURC", 5);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("PAWN", 5);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("TICKET NO.", 11);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("DATE & TIME", 16);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("LOAN AMOUNT", 11);

            row = document.CreateNewRow();
            row.WriteText(string.Empty, 7);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText(string.Empty, 6);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("X", 5);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText(string.Empty, 5);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("361208", 11);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("05/05/09 15:50", 16);
            row.WriteText(horizontalSeparatorValue);
            row.WriteText("90.00", 11);

            row = document.CreateNewRow();
            row.WriteText("-------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("-------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("------------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("-----------------");
            row.WriteText(intersectingSeparatorValue);
            row.WriteText("--------------");

            row = document.CreateNewRow();
            row.WriteText("Cashland Financial Services, Inc", 45);
            row.WriteText("PAGE 1 OF 1", 30, RawTextFlags.Right);


            var actualValue   = document.GetDocumentValue();
            var expectedValue = string.Format("{0}{1}{2}", PrinterCode.LineDensity8Dpi, PrinterCode.HorizontalSpacing171Cpi,
                                              @"NAME OF CUSTOMER                             | SERIAL NUMBER
HAMMOND, JAMES R                             |
---------------------------------------------+----------------------------
CUSTOMER SIGNATURE                           | ITEM
                                             | NUG DROP
---------------------------------------------+----------------------------
ADDRESS                                      | DESIGN / MODEL / MAKE / CAL /
8025 W.RUSSELL RD #1125                      |          SIZE / DESC.
---------------------------+----------+------+
CITY - STATE - ZIP         | DOB      | EYES | NUG DROP;Y/G;14 KT.;APPRX 8.9 GR
LAS VEGAS, NV89113         | 09/27/67 | GRN  | ORM SHAPED;
------+-------+------------+-------+--+------+
SEX   | HEIGHT| WEIGHT     | HAIR  | ORIGIN  |
M     | 5'10  |         215| BRN   | W       |
------+-------+------------+-------+---------+
IDENTIFICATION TYPE DR LIC OR VALID PHOTO ID |
DL-NV-2000407563                             |
-------+-------+------+------+------------+--+--------------+--------------
CONS   | TRADE | PURC | PAWN | TICKET NO. | DATE & TIME     | LOAN AMOUNT
       |       | X    |      | 361208     | 05/05/09 15:50  | 90.00
-------+-------+------+------+------------+-----------------+--------------
Cashland Financial Services, Inc                                PAGE 1 OF 1
");

            //Console.Write(actualValue);
            //string returnValue;
            //SendASCIIStringToPrinter("192.168.106.202", 9100, actualValue, out returnValue);
            Assert.AreEqual(expectedValue, actualValue);
            //Console.WriteLine(returnValue);
        }