Exemplo n.º 1
0
        public static void ToTextTest()
        {
            string expected = @"0000000010Mark                     
0000000200Lou                      ";
            string actual   = null;

            ChoTypeConverterFormatSpec.Instance.DateTimeFormat = "G";
            ChoTypeConverterFormatSpec.Instance.BooleanFormat  = ChoBooleanFormatSpec.YesOrNo;
            //ChoTypeConverterFormatSpec.Instance.EnumFormat = ChoEnumFormatSpec.Name;

            List <EmployeeRecSimple> objs = new List <EmployeeRecSimple>();
            EmployeeRecSimple        rec1 = new EmployeeRecSimple();

            rec1.Id   = 10;
            rec1.Name = "Mark";
            objs.Add(rec1);

            EmployeeRecSimple rec2 = new EmployeeRecSimple();

            rec2.Id   = 200;
            rec2.Name = "Lou";
            objs.Add(rec2);

            actual = ChoFixedLengthWriter.ToTextAll <EmployeeRecSimple>(objs);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public static void POCOTest()
        {
            string expected = @"Id      Name      
00000001Mark      
00000002Jason     ";
            string actual   = null;

            List <EmployeeRecSimple> objs = new List <EmployeeRecSimple>();

            EmployeeRecSimple rec1 = new EmployeeRecSimple();

            rec1.Id   = 1;
            rec1.Name = "Mark";
            objs.Add(rec1);

            EmployeeRecSimple rec2 = new EmployeeRecSimple();

            rec2.Id   = 2;
            rec2.Name = "Jason";
            objs.Add(rec2);

            using (var parser = new ChoFixedLengthWriter <EmployeeRecSimple>(FileNamePOCOTestTXT).
                                WithFirstLineHeader().
                                WithField("Id", 0, 8).
                                WithField("Name", 5, 10))
            {
                parser.Write(objs);
            }

            actual = new StreamReader(FileNamePOCOTestTXT).ReadToEnd();
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        static void ToTextTest()
        {
            ChoTypeConverterFormatSpec.Instance.DateTimeFormat = "G";
            ChoTypeConverterFormatSpec.Instance.BooleanFormat  = ChoBooleanFormatSpec.YesOrNo;
            //ChoTypeConverterFormatSpec.Instance.EnumFormat = ChoEnumFormatSpec.Name;

            List <EmployeeRecSimple> objs = new List <EmployeeRecSimple>();
            EmployeeRecSimple        rec1 = new EmployeeRecSimple();

            rec1.Id   = 10;
            rec1.Name = "Mark";
            objs.Add(rec1);

            EmployeeRecSimple rec2 = new EmployeeRecSimple();

            rec2.Id   = 200;
            rec2.Name = "Lou";
            objs.Add(rec2);

            Console.WriteLine(ChoFixedLengthWriter.ToTextAll <EmployeeRecSimple>(objs));
        }
Exemplo n.º 4
0
        static void POCOTest()
        {
            List <EmployeeRecSimple> objs = new List <EmployeeRecSimple>();

            EmployeeRecSimple rec1 = new EmployeeRecSimple();

            rec1.Id   = 1;
            rec1.Name = "Mark";
            objs.Add(rec1);

            EmployeeRecSimple rec2 = new EmployeeRecSimple();

            rec2.Id   = 2;
            rec2.Name = "Jason";
            objs.Add(rec2);

            using (var parser = new ChoFixedLengthWriter <EmployeeRecSimple>("Emp.txt").
                                WithFirstLineHeader().
                                WithField("Id", 0, 8).
                                WithField("Name", 5, 10))
            {
                parser.Write(objs);
            }
        }