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


C# TypeMapper.MapEnumType方法代码示例

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


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

示例1: MapEnumType_should_create_enum_type_with_clr_type_name_and_add_to_model

        public void MapEnumType_should_create_enum_type_with_clr_type_name_and_add_to_model()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var mockType = new MockType("Foo");

            mockType.SetupGet(t => t.IsEnum).Returns(true);
            mockType.Setup(t => t.GetEnumUnderlyingType()).Returns(typeof(int));
            mockType.Setup(t => t.GetEnumNames()).Returns(new string[] { });
            mockType.Setup(t => t.GetEnumValues()).Returns(new int[] { });

            var modelConfiguration = new ModelConfiguration();

            var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));

            var enumType = typeMapper.MapEnumType(mockType);

            Assert.NotNull(enumType);
            Assert.Same(enumType, model.GetEnumType("Foo"));
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:19,代码来源:TypeMapperTests.cs

示例2: MapEnumType_should_should_throw_for_new_type_if_entity_type_with_same_simple_name_already_used

        public void MapEnumType_should_should_throw_for_new_type_if_entity_type_with_same_simple_name_already_used()
        {
            var model = new EdmModel(DataSpace.CSpace);

            var mockType1 = new MockType("Foo");
            var mockType2 = new MockType("Foo");

            mockType2.SetupGet(t => t.IsEnum).Returns(true);

            var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));

            Assert.NotNull(typeMapper.MapEntityType(mockType1));

            Assert.Equal(
                Strings.SimpleNameCollision("Foo", "Foo", "Foo"),
                Assert.Throws<NotSupportedException>(() => typeMapper.MapEnumType(mockType2)).Message);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:17,代码来源:TypeMapperTests.cs

示例3: MapEnumType_should_set_namespace_when_provided_via_model_configuration

        public void MapEnumType_should_set_namespace_when_provided_via_model_configuration()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var mockType = new MockType("Foo");

            mockType.SetupGet(t => t.IsEnum).Returns(true);
            mockType.Setup(t => t.GetEnumUnderlyingType()).Returns(typeof(int));
            mockType.Setup(t => t.GetEnumNames()).Returns(new string[] { });
            mockType.Setup(t => t.GetEnumValues()).Returns(new int[] { });

            var modelConfiguration = new ModelConfiguration
                                         {
                                             ModelNamespace = "Bar"
                                         };

            var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));

            var enumType = typeMapper.MapEnumType(mockType);

            Assert.NotNull(enumType);
            Assert.Equal("Bar", enumType.NamespaceName);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:22,代码来源:TypeMapperTests.cs

示例4: MapComplexType_should_throw_for_new_type_if_enum_type_with_same_simple_name_already_used

        public void MapComplexType_should_throw_for_new_type_if_enum_type_with_same_simple_name_already_used()
        {
            var model = new EdmModel(DataSpace.CSpace);

            var mockType1 = new MockType("Foo");
            var mockType2 = new MockType("Foo");

            var modelConfiguration = new ModelConfiguration();
            modelConfiguration.ComplexType(mockType2);

            mockType1.SetupGet(t => t.IsEnum).Returns(true);
            mockType1.Setup(t => t.GetEnumUnderlyingType()).Returns(typeof(int));
            mockType1.Setup(t => t.GetEnumNames()).Returns(new string[] { });
            mockType1.Setup(t => t.GetEnumValues()).Returns(new int[] { });

            var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));

            Assert.NotNull(typeMapper.MapEnumType(mockType1));

            Assert.Equal(
                Strings.SimpleNameCollision("Foo", "Foo", "Foo"),
                Assert.Throws<NotSupportedException>(() => typeMapper.MapComplexType(mockType2)).Message);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:23,代码来源:TypeMapperTests.cs

示例5: MapEnumType_should_ignore_new_type_if_type_name_already_used

        public void MapEnumType_should_ignore_new_type_if_type_name_already_used()
        {
            var model = new EdmModel().Initialize();

            var mockType1 = new MockType("Foo");
            var mockType2 = new MockType("Foo");

            mockType1.SetupGet(t => t.IsEnum).Returns(true);
            mockType1.Setup(t => t.GetEnumUnderlyingType()).Returns(typeof(int));
            mockType1.Setup(t => t.GetEnumNames()).Returns(new string[] { });
            mockType1.Setup(t => t.GetEnumValues()).Returns(new int[] { });
            mockType2.SetupGet(t => t.IsEnum).Returns(true);

            var modelConfiguration = new ModelConfiguration();
            var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));

            Assert.NotNull(typeMapper.MapEnumType(mockType1));
            Assert.Null(typeMapper.MapEnumType(mockType2));
        }
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:19,代码来源:TypeMapperTests.cs

示例6: MapEnumType_should_create_enum_type_with_clr_type_name_and_add_to_model

        public void MapEnumType_should_create_enum_type_with_clr_type_name_and_add_to_model()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var modelConfiguration = new ModelConfiguration();
            var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));

            var enumType = typeMapper.MapEnumType(typeof(AnEnum1));

            Assert.NotNull(enumType);
            Assert.Same(enumType, model.GetEnumType("AnEnum1"));
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:TypeMapperTests.cs

示例7: MapEnumType_should_set_namespace_when_provided_via_model_configuration

        public void MapEnumType_should_set_namespace_when_provided_via_model_configuration()
        {
            var model = new EdmModel(DataSpace.CSpace);
            var modelConfiguration = new ModelConfiguration
                                         {
                                             ModelNamespace = "Bar"
                                         };
            var typeMapper = new TypeMapper(new MappingContext(modelConfiguration, new ConventionsConfiguration(), model));

            var enumType = typeMapper.MapEnumType(typeof(AnEnum1));

            Assert.NotNull(enumType);
            Assert.Equal("Bar", enumType.NamespaceName);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:TypeMapperTests.cs

示例8: MapEnumType_should_should_throw_for_new_type_if_entity_type_with_same_simple_name_already_used

        public void MapEnumType_should_should_throw_for_new_type_if_entity_type_with_same_simple_name_already_used()
        {
            var model = new EdmModel(DataSpace.CSpace);

            var typeMapper = new TypeMapper(new MappingContext(new ModelConfiguration(), new ConventionsConfiguration(), model));

            Assert.NotNull(typeMapper.MapEntityType(typeof(Outer5.AType5)));

            Assert.Equal(
                Strings.SimpleNameCollision(typeof(AType5).FullName, typeof(Outer5.AType5).FullName, "AType5"),
                Assert.Throws<NotSupportedException>(() => typeMapper.MapEnumType(typeof(AType5))).Message);
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:TypeMapperTests.cs


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