private DocumentFormatDefinitionBuilder<ChequeRow> GetDefinition()
 {
     var definition = new DocumentFormatDefinitionBuilder<ChequeRow>(string.Empty, false);
     definition.AddColumn(q => q.AccountNo,
                          c => c.SetColumnWidth(12).SetAlignment(ColumnAlignment.Right).SetFillChar('0').ThrowOnOverflow());
     definition.AddColumn(q => q.RecordType, c => c.SetExportFunc(EnumConvertFunc));
     definition.AddColumn(q => q.SerialNumber,
                          c => c.SetColumnWidth(10).SetAlignment(ColumnAlignment.Right).SetFillChar('0').ThrowOnOverflow());
     definition.AddColumn(q => q.AmountCents,
                          c => c.SetColumnWidth(12).SetAlignment(ColumnAlignment.Right).SetFillChar('0').ThrowOnOverflow());
     definition.AddColumn(q => q.Date,
                          c => c.SetColumnWidth(8).SetStringFormat("yyyyMMdd"));
     definition.AddDummyColumn(1);
     definition.AddDummyColumn(50);
     definition.AddDummyColumn(16);
     definition.AddDummyColumn(256);
     definition.AddDummyColumn(16);
     definition.SetExportHeaderLine(false);
     definition.SetTrimLineEnds(false);
     return definition;
 }
        public void Add_Columns_Manually_Test()
        {
            Type type = typeof (Measurement);

            DocumentFormatDefinitionBuilder<Measurement> builder = new DocumentFormatDefinitionBuilder<Measurement>("\t", true)
                .SetCommentString("'")
                .SetExportHeaderLine(true, "' ");

            builder.AddColumn(type.GetProperty("Name"));
            builder.AddColumn(type.GetProperty("X"), "0.000");
            builder.AddColumn(type.GetProperty("Y"), "0.000");
            builder.AddColumn(type.GetProperty("Z"), "0.000");
            builder.AddColumn(type.GetProperty("DateTime"), "dd.MM.yyyy HH:mm:ss");
            builder.AddColumn(type.GetProperty("IsActive"));

            IDocumentFormatDefinition<Measurement> definition = builder.Build();

            string exportResult = definition.Export(new[] {_measurement});

            Assert.AreEqual(@"' Name 	X     	Y     	Z     	DateTime           	IsActive
            Point01	10.000	20.000	30.000	03.03.2013 14:48:00	T", exportResult);

            List<Measurement> importList = definition.Import(exportResult);
            AssertAreEqual(importList);
        }
Beispiel #3
0
        public void Add_Columns_Manually_Test()
        {
            Type type = typeof(Measurement);

            DocumentFormatDefinitionBuilder <Measurement> builder = new DocumentFormatDefinitionBuilder <Measurement>("\t", true)
                                                                    .SetCommentString("'")
                                                                    .SetExportHeaderLine(true, "' ");

            builder.AddColumn(type.GetProperty("Name"));
            builder.AddColumn(type.GetProperty("X"), "0.000");
            builder.AddColumn(type.GetProperty("Y"), "0.000");
            builder.AddColumn(type.GetProperty("Z"), "0.000");
            builder.AddColumn(type.GetProperty("DateTime"), "dd.MM.yyyy HH:mm:ss");
            builder.AddColumn(type.GetProperty("IsActive"));

            IDocumentFormatDefinition <Measurement> definition = builder.Build();

            string exportResult = definition.Export(new[] { _measurement });

            Assert.AreEqual(@"' Name    X       Y       Z       DateTime            IsActive
Point01	10.000	20.000	30.000	03.03.2013 14:48:00	T"    , exportResult);

            List <Measurement> importList = definition.Import(exportResult);

            AssertAreEqual(importList);
        }
        private DocumentFormatDefinitionBuilder <ChequeRow> GetDefinition()
        {
            var definition = new DocumentFormatDefinitionBuilder <ChequeRow>(string.Empty, false);

            definition.AddColumn(q => q.AccountNo,
                                 c => c.SetColumnWidth(12).SetAlignment(ColumnAlignment.Right).SetFillChar('0').ThrowOnOverflow());
            definition.AddColumn(q => q.RecordType, c => c.SetExportFunc(EnumConvertFunc));
            definition.AddColumn(q => q.SerialNumber,
                                 c => c.SetColumnWidth(10).SetAlignment(ColumnAlignment.Right).SetFillChar('0').ThrowOnOverflow());
            definition.AddColumn(q => q.AmountCents,
                                 c => c.SetColumnWidth(12).SetAlignment(ColumnAlignment.Right).SetFillChar('0').ThrowOnOverflow());
            definition.AddColumn(q => q.Date,
                                 c => c.SetColumnWidth(8).SetStringFormat("yyyyMMdd"));
            definition.AddDummyColumn(1);
            definition.AddDummyColumn(50);
            definition.AddDummyColumn(16);
            definition.AddDummyColumn(256);
            definition.AddDummyColumn(16);
            definition.SetExportHeaderLine(false);
            definition.SetTrimLineEnds(false);
            return(definition);
        }