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


C# MockType.Property方法代码示例

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


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

示例1: Apply_ignores_constraint_when_inverse_constraint_already_specified

        public void Apply_ignores_constraint_when_inverse_constraint_already_specified()
        {
            var mockTypeA = new MockType("A");
            var mockTypeB = new MockType("B").Property(mockTypeA, "A").Property<int>("AId1").Property<int>("AId2");
            mockTypeA.Property(mockTypeB, "B");

            var mockPropertyInfo = mockTypeA.GetProperty("B");
            var mockInversePropertyInfo = mockTypeB.GetProperty("A");

            var modelConfiguration = new ModelConfiguration();
            var navigationPropertyConfiguration
                = modelConfiguration.Entity(mockTypeA).Navigation(mockPropertyInfo);

            var inverseNavigationPropertyConfiguration
                = modelConfiguration.Entity(mockTypeB).Navigation(mockInversePropertyInfo);

            navigationPropertyConfiguration.InverseNavigationProperty = mockInversePropertyInfo;

            inverseNavigationPropertyConfiguration.Constraint
                = new ForeignKeyConstraintConfiguration(new[] { mockTypeB.GetProperty("AId1") });

            new ForeignKeyPrimitivePropertyAttributeConvention.ForeignKeyAttributeConventionImpl()
                .Apply(mockPropertyInfo, modelConfiguration, new ForeignKeyAttribute("AId2"));

            Assert.Null(navigationPropertyConfiguration.Constraint);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:26,代码来源:ForeignKeyAttributeConventionTests.cs

示例2: Configure_should_uniquify_unconfigured_assocation_function_names

        public void Configure_should_uniquify_unconfigured_assocation_function_names()
        {
            var typeA = new MockType("A");
            var typeB = new MockType("B").Property(typeA.AsCollection(), "As");
            var mockPropertyInfo = typeB.GetProperty("As");
            typeA.Property(typeB.AsCollection(), "Bs");

            var modelConfiguration = new ModelConfiguration();

            var navigationPropertyConfiguration
                = modelConfiguration.Entity(typeB).Navigation(mockPropertyInfo);

            navigationPropertyConfiguration.ModificationFunctionsConfiguration
                = new ModificationFunctionsConfiguration();

            var modificationFunctionConfiguration = new ModificationFunctionConfiguration();
            modificationFunctionConfiguration.HasName("M2M_Delete");

            navigationPropertyConfiguration.ModificationFunctionsConfiguration
                .Insert(modificationFunctionConfiguration);

            var model = new EdmModel(DataSpace.CSpace);

            var entityA = model.AddEntityType("A");
            entityA.Annotations.SetClrType(typeA);
            entityA.SetConfiguration(modelConfiguration.Entity(typeA));

            var entityB = model.AddEntityType("B");
            entityB.Annotations.SetClrType(typeB);
            entityB.SetConfiguration(modelConfiguration.Entity(typeB));

            model.AddEntitySet("AS", entityA);
            model.AddEntitySet("BS", entityB);

            var associationType
                = model.AddAssociationType(
                    "M2M",
                    entityA,
                    RelationshipMultiplicity.Many,
                    entityB,
                    RelationshipMultiplicity.Many);

            associationType.SetConfiguration(navigationPropertyConfiguration);

            var navigationProperty
                = entityB.AddNavigationProperty("As", associationType);

            navigationProperty.SetClrPropertyInfo(mockPropertyInfo);

            model.AddAssociationSet("M2MSet", associationType);

            var databaseMapping
                = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest)
                    .Generate(model);

            modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);

            Assert.True(databaseMapping.Database.Functions.Any(f => f.Name == "M2M_Delete"));
            Assert.True(databaseMapping.Database.Functions.Any(f => f.Name == "M2M_Delete1"));
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:60,代码来源:ModelConfigurationTests.cs

示例3: Apply_finds_inverse_when_many_to_many

        public void Apply_finds_inverse_when_many_to_many()
        {
            var mockTypeA = new MockType("A");
            var mockTypeB = new MockType("B").Property(mockTypeA.AsCollection(), "As");
            var mockPropertyInfo = mockTypeB.GetProperty("As");
            mockTypeA.Property(mockTypeB.AsCollection(), "Bs");
            var modelConfiguration = new ModelConfiguration();

            new InversePropertyAttributeConvention()
                .Apply(mockPropertyInfo, modelConfiguration, new InversePropertyAttribute("Bs"));

            var navigationPropertyConfiguration
                = modelConfiguration.Entity(mockTypeB).Navigation(mockPropertyInfo);

            Assert.Same(mockTypeA.GetProperty("Bs"), navigationPropertyConfiguration.InverseNavigationProperty);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:16,代码来源:InversePropertyAttributeConventionTests.cs

示例4: Apply_ignores_constraint_when_already_specified

        public void Apply_ignores_constraint_when_already_specified()
        {
            var mockTypeA = new MockType("A");
            var mockTypeB = new MockType("B").Property<int>("AId1").Property<int>("AId2");
            mockTypeA.Property(mockTypeB, "B");
            var mockPropertyInfo = mockTypeA.GetProperty("B");
            var modelConfiguration = new ModelConfiguration();
            var navigationPropertyConfiguration
                = modelConfiguration.Entity(mockTypeA).Navigation(mockPropertyInfo);
            navigationPropertyConfiguration.Constraint
                = new ForeignKeyConstraintConfiguration(new[] { mockTypeB.GetProperty("AId1") });

            new ForeignKeyPrimitivePropertyAttributeConvention.ForeignKeyAttributeConventionImpl()
                .Apply(mockPropertyInfo, modelConfiguration, new ForeignKeyAttribute("AId2"));

            var foreignKeyConstraint = (ForeignKeyConstraintConfiguration)navigationPropertyConfiguration.Constraint;

            Assert.Equal(new[] { mockTypeB.GetProperty("AId1") }, foreignKeyConstraint.DependentProperties);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:19,代码来源:ForeignKeyAttributeConventionTests.cs

示例5: Apply_ignores_inverse_when_already_configured

        public void Apply_ignores_inverse_when_already_configured()
        {
            var mockTypeA = new MockType("A");
            var mockTypeB = new MockType("B").Property(mockTypeA, "A1").Property(mockTypeA, "A2");
            mockTypeA.Property(mockTypeB, "B");
            var mockPropertyInfo = mockTypeA.GetProperty("B");
            var modelConfiguration = new ModelConfiguration();
            var navigationPropertyConfiguration
                = modelConfiguration.Entity(mockTypeA).Navigation(mockPropertyInfo);
            navigationPropertyConfiguration.InverseNavigationProperty = mockTypeB.GetProperty("A2");

            new InversePropertyAttributeConvention()
                .Apply(mockPropertyInfo, modelConfiguration, new InversePropertyAttribute("A1"));

            Assert.NotSame(mockTypeB.GetProperty("A1"), navigationPropertyConfiguration.InverseNavigationProperty);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:16,代码来源:InversePropertyAttributeConventionTests.cs

示例6: Apply_throws_when_cannot_find_inverse_property

        public void Apply_throws_when_cannot_find_inverse_property()
        {
            var mockTypeA = new MockType("A");
            var mockTypeB = new MockType("B");
            mockTypeA.Property(mockTypeB, "B");
            var mockPropertyInfo = mockTypeA.GetProperty("B");
            var modelConfiguration = new ModelConfiguration();

            Assert.Equal(
                Strings.InversePropertyAttributeConvention_PropertyNotFound("Foo", mockTypeB.Object, "B", mockTypeA.Object),
                Assert.Throws<InvalidOperationException>(
                    () => new InversePropertyAttributeConvention()
                              .Apply(mockPropertyInfo, modelConfiguration, new InversePropertyAttribute("Foo"))).Message);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:14,代码来源:InversePropertyAttributeConventionTests.cs

示例7: Apply_throws_on_self_inverse

        public void Apply_throws_on_self_inverse()
        {
            var mockTypeA = new MockType("A");
            mockTypeA.Property(mockTypeA, "A");
            var mockPropertyInfo = mockTypeA.GetProperty("A");
            var modelConfiguration = new ModelConfiguration();

            Assert.Equal(
                Strings.InversePropertyAttributeConvention_SelfInverseDetected("A", mockTypeA.Object),
                Assert.Throws<InvalidOperationException>(
                    () => new InversePropertyAttributeConvention()
                              .Apply(mockPropertyInfo, modelConfiguration, new InversePropertyAttribute("A"))).Message);
        }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:13,代码来源:InversePropertyAttributeConventionTests.cs

示例8: Apply_throws_when_cannot_find_navigation_property

        public void Apply_throws_when_cannot_find_navigation_property()
        {
            var mockTypeA = new MockType("A");
            mockTypeA.Property(typeof(int), "BId");
            var mockPropertyInfo = mockTypeA.GetProperty("BId");

            Assert.Equal(
                Strings.ForeignKeyAttributeConvention_InvalidNavigationProperty("BId", mockTypeA.Object, "Missing"),
                Assert.Throws<InvalidOperationException>(
                    () => new ForeignKeyPrimitivePropertyAttributeConvention.ForeignKeyAttributeConventionImpl()
                              .Apply(mockPropertyInfo, new ModelConfiguration(), new ForeignKeyAttribute("Missing"))).Message);
        }
开发者ID:junxy,项目名称:entityframework,代码行数:12,代码来源:ForeignKeyAttributeConventionTests.cs


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