Пример #1
0
        public void ObjectToObject()
        {
            Test16 test16 = new Test16
            {
                COGS               = "COGS",
                Country            = "Country",
                Date               = new DateTime(2018, 5, 2),
                DiscountBand       = "DiscountBand",
                Discounts          = "Discounts",
                GrossSales         = "GrossSales",
                ManufacturingPrice = "ManufacturingPrice",
                MonthName          = "MonthName",
                MonthNumber        = 5,
                Product            = "Product",
                Profit             = "Profit",
                SalePrice          = "SalePrice",
                Sales              = "Sales",
                Segment            = "Segment",
                UnitsSold          = 2.6m,
                Year               = 2017
            };
            Test6   test6         = Converters.Converters.ObjectToObject <Test16, Test6>()(test16);
            Test16S test16s       = Converters.Converters.ObjectToObject <Test16, Test16S>()(test16);
            Test16  test16from6   = Converters.Converters.ObjectToObject <Test6, Test16>()(test6);
            Test16  test16from16s = Converters.Converters.ObjectToObject <Test16S, Test16>()(test16s);

            TestEquality(test6, test16);
            TestEquality(test16, test6);
            TestEquality(test16, test16s);
            TestEquality(test6, test16from6);
            TestEquality(test16, test16from16s);
        }
Пример #2
0
        public void ListToObject()
        {
            List <string> names = new List <string>()
            {
                "Segment",
                "Country",
                "Product",
                "DiscountBand",
                "UnitsSold",
                "ManufacturingPrice",
                "SalePrice",
                //"GrossSales",
                "Discounts",
                "Sales",
                "COGS",
                "Profit",
                "Date",
                "MonthNumber",
                "MonthName",
                "Year",
                "BADDATA1",
                //"GrossSales",
                "BAD DATA 2",
            };
            List <object> values = new List <object>()
            {
                "Segment",
                "Country",
                "Product",
                "DiscountBand",
                2.6m,
                "ManufacturingPrice",
                "SalePrice",
                //"GrossSales",
                "Discounts",
                "Sales",
                "COGS",
                "Profit",
                new DateTime(2018, 5, 2),
                5,
                "MonthName",
                2017,
                "BADDATA1",
                //"GrossSales",
                "BAD DATA 2"
            };
            List <string> valuesStr = new List <string>()
            {
                "Segment",
                "Country",
                "Product",
                "DiscountBand",
                "2.6",
                "ManufacturingPrice",
                "SalePrice",
                //"GrossSales",
                "Discounts",
                "Sales",
                "COGS",
                "Profit",
                new DateTime(2018, 5, 2).ToString(),
                "5",
                "MonthName",
                "2017",
                "BADDATA1",
                //"GrossSales",
                "BAD DATA 2",
            };

            Test16 test16  = Converters.Converters.ListToObject <object, Test16>(names)(values);
            Test16 test16B = Converters.Converters.ListToObject <string, Test16>(names)(valuesStr);

            Test16S test16s  = Converters.Converters.ListToObject <object, Test16S>(names)(values);
            Test16S test16sB = Converters.Converters.ListToObject <string, Test16S>(names)(valuesStr);

            Test6 test6  = Converters.Converters.ListToObject <object, Test6>(names)(values);
            Test6 test6B = Converters.Converters.ListToObject <string, Test6>(names)(valuesStr);
        }