本文整理汇总了C#中MockPropertyInfo类的典型用法代码示例。如果您正苦于以下问题:C# MockPropertyInfo类的具体用法?C# MockPropertyInfo怎么用?C# MockPropertyInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockPropertyInfo类属于命名空间,在下文中一共展示了MockPropertyInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidStructuralProperty_should_return_false_when_property_read_only
public void IsValidStructuralProperty_should_return_false_when_property_read_only()
{
var mockProperty = new MockPropertyInfo();
mockProperty.SetupGet(p => p.CanWrite).Returns(false);
Assert.False(mockProperty.Object.IsValidStructuralProperty());
}
示例2: IsValidStructuralProperty_should_return_true_when_property_read_only_collection
public void IsValidStructuralProperty_should_return_true_when_property_read_only_collection()
{
var mockProperty = new MockPropertyInfo(typeof(List<string>), "P");
mockProperty.SetupGet(p => p.CanWrite).Returns(false);
Assert.True(mockProperty.Object.IsValidStructuralProperty());
}
示例3: IsValidStructuralProperty_should_return_false_for_indexed_property
public void IsValidStructuralProperty_should_return_false_for_indexed_property()
{
var mockProperty = new MockPropertyInfo();
mockProperty.Setup(p => p.GetIndexParameters()).Returns(new ParameterInfo[1]);
Assert.False(mockProperty.Object.IsValidStructuralProperty());
}
示例4: Apply_should_transfer_constraint_and_clr_property_info_annotation
public void Apply_should_transfer_constraint_and_clr_property_info_annotation()
{
EdmModel model
= new TestModelBuilder()
.Entities("S", "T")
.Association("S", RelationshipMultiplicity.ZeroOrOne, "T", RelationshipMultiplicity.Many)
.Association("T", RelationshipMultiplicity.Many, "S", RelationshipMultiplicity.ZeroOrOne);
var association2 = model.AssociationTypes.Last();
var mockPropertyInfo = new MockPropertyInfo();
association2.SourceEnd.SetClrPropertyInfo(mockPropertyInfo);
var referentialConstraint
= new ReferentialConstraint(
association2.SourceEnd,
association2.TargetEnd,
new[] { new EdmProperty("P") },
new[] { new EdmProperty("D") });
association2.Constraint = referentialConstraint;
((IEdmConvention)new AssociationInverseDiscoveryConvention()).Apply(model);
Assert.Equal(1, model.AssociationTypes.Count());
Assert.Equal(1, model.Containers.Single().AssociationSets.Count());
var associationType = model.AssociationTypes.Single();
Assert.NotSame(association2, associationType);
Assert.Same(referentialConstraint, associationType.Constraint);
Assert.Same(associationType.SourceEnd, referentialConstraint.FromRole);
Assert.Same(associationType.TargetEnd, referentialConstraint.ToRole);
Assert.Same(mockPropertyInfo.Object, associationType.TargetEnd.GetClrPropertyInfo());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:35,代码来源:AssociationInverseDiscoveryConventionTests.cs
示例5: Configure_should_configure_inverse
public void Configure_should_configure_inverse()
{
var inverseMockPropertyInfo = new MockPropertyInfo();
var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo())
{
InverseNavigationProperty = inverseMockPropertyInfo
};
var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
associationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));
var inverseAssociationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace);
inverseAssociationType.SourceEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
inverseAssociationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace));
var model = new EdmModel(DataSpace.CSpace);
model.AddAssociationType(inverseAssociationType);
var inverseNavigationProperty
= model.AddEntityType("T")
.AddNavigationProperty("N", inverseAssociationType);
inverseNavigationProperty.SetClrPropertyInfo(inverseMockPropertyInfo);
navigationPropertyConfiguration.Configure(
new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType()))
{
RelationshipType = associationType
}, model, new EntityTypeConfiguration(typeof(object)));
Assert.Same(associationType, inverseNavigationProperty.Association);
Assert.Same(associationType.SourceEnd, inverseNavigationProperty.ResultEnd);
Assert.Same(associationType.TargetEnd, inverseNavigationProperty.FromEndMember);
Assert.Equal(0, model.AssociationTypes.Count());
}
示例6: Inverse_navigation_property_should_throw_when_self_inverse
public void Inverse_navigation_property_should_throw_when_self_inverse()
{
var mockPropertyInfo = new MockPropertyInfo();
var navigationPropertyConfiguration = new NavigationPropertyConfiguration(mockPropertyInfo);
Assert.Equal(Strings.NavigationInverseItself("P", typeof(object)), Assert.Throws<InvalidOperationException>(() => navigationPropertyConfiguration.InverseNavigationProperty = mockPropertyInfo).Message);
}
示例7: Configure_should_rename_table_when_table_configured
public void Configure_should_rename_table_when_table_configured()
{
var database = new EdmModel(DataSpace.SSpace);
var table = database.AddTable("OriginalName");
var associationSetMapping
= new StorageAssociationSetMapping(
new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)),
database.GetEntitySet(table))
.Initialize();
var manyToManyAssociationMappingConfiguration
= new ManyToManyAssociationMappingConfiguration();
manyToManyAssociationMappingConfiguration.ToTable("NewName");
var mockPropertyInfo = new MockPropertyInfo();
associationSetMapping.SourceEndMapping.EndMember = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
associationSetMapping.SourceEndMapping.EndMember.SetClrPropertyInfo(mockPropertyInfo);
manyToManyAssociationMappingConfiguration.Configure(associationSetMapping, database, mockPropertyInfo);
Assert.Equal("NewName", table.GetTableName().Name);
Assert.Same(manyToManyAssociationMappingConfiguration, table.GetConfiguration());
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:26,代码来源:ManyToManyAssociationMappingConfigurationTests.cs
示例8: Configure_should_configure_inverse
public void Configure_should_configure_inverse()
{
var inverseMockPropertyInfo = new MockPropertyInfo();
var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo())
{
InverseNavigationProperty = inverseMockPropertyInfo
};
var associationType = new EdmAssociationType().Initialize();
var inverseAssociationType = new EdmAssociationType().Initialize();
var model = new EdmModel().Initialize();
model.AddAssociationType(inverseAssociationType);
var inverseNavigationProperty
= model.AddEntityType("T")
.AddNavigationProperty("N", inverseAssociationType);
inverseNavigationProperty.SetClrPropertyInfo(inverseMockPropertyInfo);
navigationPropertyConfiguration.Configure(
new EdmNavigationProperty
{
Association = associationType
}, model, new EntityTypeConfiguration(typeof(object)));
Assert.Same(associationType, inverseNavigationProperty.Association);
Assert.Same(associationType.SourceEnd, inverseNavigationProperty.ResultEnd);
Assert.Equal(0, model.GetAssociationTypes().Count());
}
示例9: Can_set_column_name_for_result_binding
public void Can_set_column_name_for_result_binding()
{
var modificationFunctionConfiguration = new ModificationFunctionConfiguration();
var mockPropertyInfo = new MockPropertyInfo();
modificationFunctionConfiguration.Result(new PropertyPath(mockPropertyInfo), "foo");
Assert.Same("foo", modificationFunctionConfiguration.ResultBindings.Single().Value);
}
示例10: Apply_should_find_single_key
public void Apply_should_find_single_key()
{
var mockPropertyInfo = new MockPropertyInfo(typeof(int), "Id");
var mockEntityTypeConfiguration = new Mock<EntityTypeConfiguration>(typeof(object));
new KeyAttributeConvention.KeyAttributeConventionImpl()
.Apply(mockPropertyInfo, mockEntityTypeConfiguration.Object, new KeyAttribute());
mockEntityTypeConfiguration.Verify(e => e.Key(mockPropertyInfo, null));
}
示例11: Apply_should_ignore_property
public void Apply_should_ignore_property()
{
var mockPropertyInfo = new MockPropertyInfo();
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
new NotMappedPropertyAttributeConvention.NotMappedPropertyAttributeConventionImpl()
.Apply(mockPropertyInfo, entityTypeConfiguration, new NotMappedAttribute());
Assert.True(entityTypeConfiguration.IgnoredProperties.Contains(mockPropertyInfo));
}
示例12: Equals_should_compare_references_or_dependent_key_sequences
public void Equals_should_compare_references_or_dependent_key_sequences()
{
var propertyInfo = new MockPropertyInfo().Object;
var constraintConfiguration1 = new ForeignKeyConstraintConfiguration(new[] { propertyInfo });
Assert.True(constraintConfiguration1.Equals(constraintConfiguration1));
var constraintConfiguration2 = new ForeignKeyConstraintConfiguration(new[] { propertyInfo });
Assert.True(constraintConfiguration1.Equals(constraintConfiguration2));
}
示例13: Can_add_parameter_configuration
public void Can_add_parameter_configuration()
{
var modificationFunctionConfiguration = new ModificationFunctionConfiguration();
Assert.Empty(modificationFunctionConfiguration.ParameterNames);
var mockPropertyInfo = new MockPropertyInfo();
modificationFunctionConfiguration.Parameter(new PropertyPath(mockPropertyInfo), "baz");
Assert.Equal("baz", modificationFunctionConfiguration.ParameterNames.Single().Value.Item1);
}
示例14: HasConstraint_sets_and_configures_the_ForeignKeyConstraint
public void HasConstraint_sets_and_configures_the_ForeignKeyConstraint()
{
var property = new MockPropertyInfo();
var configuration =
new NavigationPropertyConfiguration(
typeof(LightweighEntity).GetDeclaredProperty("ValidNavigationProperty"));
var lightweightConfiguration = new ConventionNavigationPropertyConfiguration(configuration, new ModelConfiguration());
lightweightConfiguration.HasConstraint<ForeignKeyConstraintConfiguration>(c => c.AddColumn(property));
Assert.IsType<ForeignKeyConstraintConfiguration>(configuration.Constraint);
Assert.Same(property.Object, ((ForeignKeyConstraintConfiguration)configuration.Constraint).ToProperties.Single());
}
示例15: IsIgnoredProperty_should_return_true_if_property_is_ignored
public void IsIgnoredProperty_should_return_true_if_property_is_ignored()
{
var modelConfiguration = new ModelConfiguration();
var mockType = new MockType();
var mockPropertyInfo = new MockPropertyInfo(typeof(string), "S");
Assert.False(modelConfiguration.IsIgnoredProperty(mockType, mockPropertyInfo));
modelConfiguration.Entity(mockType).Ignore(mockPropertyInfo);
Assert.True(modelConfiguration.IsIgnoredProperty(mockType, mockPropertyInfo));
}