当前位置: 首页>>代码示例>>C#>>正文


C# Converter.ConvertDynamic方法代码示例

本文整理汇总了C#中Converter.ConvertDynamic方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.ConvertDynamic方法的具体用法?C# Converter.ConvertDynamic怎么用?C# Converter.ConvertDynamic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Converter的用法示例。


在下文中一共展示了Converter.ConvertDynamic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert_DynamicObjectWithInvalidColumnName_ShouldThrowInvalidColumnException

        public void Convert_DynamicObjectWithInvalidColumnName_ShouldThrowInvalidColumnException(Converter sut)
        {
            //Setup
            var invalidColumnName = "address..zipCode";
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, invalidColumnName, "firstName1" }
            };

            //Exercise
            Action exercise = () => sut.ConvertDynamic(columns, matrix);

            //Verify
            exercise.ShouldThrow<ConverterInvalidColumnNameException>()
                .Where(x => x.Message.Contains(invalidColumnName));
        }
开发者ID:tgropper,项目名称:Bardock.R2O,代码行数:21,代码来源:ConverterTest.cs

示例2: Convert_NestedDynamicObject_ShouldSucced

        public void Convert_NestedDynamicObject_ShouldSucced(Converter sut)
        {
            //Setup
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, "city.name", "cityName" },
                new List<object>() { 1, "city.country.isoCode", "countryIsoCode" },
                new List<object>() { 2, "school.name", "schoolName" }
            };

            //Exercise
            var actual = sut.ConvertDynamic(columns, matrix);

            //Verify
            actual.Should().HaveCount(2)
                .And.DeepContain(new Dictionary<string, object>()
                {
                    { "id", 1},
                    { "city", new Dictionary<string, object>()
                        {
                            { "name", "cityName" },
                            { "country", new Dictionary<string, object>()
                                {
                                    { "isoCode", "countryIsoCode" }
                                }
                           }
                        }
                    }
                })
                .And.DeepContain(new Dictionary<string, object>()
                {
                    { "id", 2},
                    { "school", new Dictionary<string, object>()
                        {
                            { "name", "schoolName" }
                        }
                    }
                });
        }
开发者ID:tgropper,项目名称:Bardock.R2O,代码行数:44,代码来源:ConverterTest.cs

示例3: Convert_DynamicObjectWithRepeatedColumns_ShouldThrowRepeatedColumnException

        public void Convert_DynamicObjectWithRepeatedColumns_ShouldThrowRepeatedColumnException(Converter sut)
        {
            //Setup
            var repeatedLabelName = "firstName";
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, repeatedLabelName, "firstName1" },
                new List<object>() { 1, repeatedLabelName, "firstName2" }
            };

            //Exercise
            Action exercise = () => sut.ConvertDynamic(columns, matrix);

            //Verify
            exercise.ShouldThrow<ConverterRepeatedColumnException>()
                .Where(x => x.Message.Contains(repeatedLabelName));
        }
开发者ID:tgropper,项目名称:Bardock.R2O,代码行数:22,代码来源:ConverterTest.cs

示例4: Convert_SimpleDynamicObject_ShouldSucced

        public void Convert_SimpleDynamicObject_ShouldSucced(Converter sut)
        {
            //Setup
            var columns = new List<string>() {
                "id",
                "name",
                "value"
            };
            var matrix = new List<List<object>>()
            {
                new List<object>() { 1, "firstName", "firstName" },
                new List<object>() { 1, "lastName", "lastName" },
                new List<object>() { 2, "hasPets", true }
            };

            //Exercise
            var actual = sut.ConvertDynamic(columns, matrix);

            //Verify
            actual.Should().NotBeEmpty()
                .And.HaveCount(2)
                .And.DeepContain(new Dictionary<string, object>() { { "id", 1 }, { "firstName", "firstName" }, { "lastName", "lastName" } })
                .And.DeepContain(new Dictionary<string, object>() { { "id", 2 }, { "hasPets", true } });
        }
开发者ID:tgropper,项目名称:Bardock.R2O,代码行数:24,代码来源:ConverterTest.cs


注:本文中的Converter.ConvertDynamic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。