예제 #1
0
        private string Header(Type t)
        {
            var header = CsvFunctions.ToHeader(t, defaultConfig);

            Console.WriteLine(header);
            return(header);
        }
예제 #2
0
        public void NewlineCollectionStrategyShouldHavePropertiesOfCollectionTypeInHeader()
        {
            var _case  = new CollectionTestCase();
            var t      = _case.GetType();
            var header = CsvFunctions.ToHeader(t, new CsvConfig(';', CollectionStrategy.Newline));

            Console.WriteLine(header);
            var expected = "x;y;z";

            Assert.AreEqual(expected, header);
        }
예제 #3
0
        public void InlineCollectionStrategyShouldHaveCollectionNameInHeader()
        {
            var _case  = new CollectionTestCase();
            var t      = _case.GetType();
            var header = CsvFunctions.ToHeader(t, new CsvConfig(';', CollectionStrategy.Inline));

            Console.WriteLine(header);
            var expected = nameof(_case.ints);

            Assert.AreEqual(expected, header);
        }
        public void Test()
        {
            var emf     = new EMFPackage(1, 2, 3, 4, 5, 6, 7, 8, 9);
            var imu     = new IMUPackage(10, 11, 12, 13, 14, 15);
            var package = new EMF_IMU_MetaPackage(emf, imu, 0, 0, 0, 1, 34);
            var config  = new CsvConfig(';');

            Console.WriteLine(
                CsvFunctions
                .ToHeader(
                    type: typeof(EMF_IMU_MetaPackage),
                    config: config
                    )
                );;
            Console.WriteLine(
                CsvFunctions
                .ToLine(
                    baseObject: package,
                    config: new CsvConfig(';')
                    )
                );
        }
예제 #5
0
        public void TestNestedClasses()
        {
            var c = new TestNestedClassAndStruct()
            {
                PublicClassProperty = new NestedClass
                {
                    nestedPublicClassField    = 1,
                    NestedPublicClassProperty = 2
                },
                PublicStructProperty = new NestedStruct
                {
                    publicNestedStructField    = 3,
                    PublicNestedStructProperty = 4
                }
            };
            var line   = Line(c);
            var header = CsvFunctions.ToHeader(c.GetType(), defaultConfig);

            Console.WriteLine(header);
            var lineTerms = line.Split(defaultConfig.delimiter);
            var d         = defaultConfig.delimiter;

            Assert.AreEqual($"2{d}1{d}4{d}3", line);
        }