public void GetMetadata_ForBaseClass() { DomainModelConstraintProviderStub .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BaseString"))) .Return(true); DomainModelConstraintProviderStub .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BaseUnidirectionalOneToOne"))) .Return(true); DomainModelConstraintProviderStub .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "BasePrivateUnidirectionalOneToOne"))) .Return(true); DomainModelConstraintProviderStub .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "String"))) .Return(true); DomainModelConstraintProviderStub .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "UnidirectionalOneToOne"))) .Return(true); DomainModelConstraintProviderStub .Stub(stub => stub.IsNullable(Arg <IPropertyInformation> .Matches(pi => pi.Name == "PrivateString"))) .Return(true); ClassIDProviderStub.Stub(stub => stub.GetClassID(typeof(ClassWithDifferentProperties))).Return("ClassWithDifferentProperties"); var classReflector = CreateClassReflector(typeof(ClassWithDifferentProperties)); var expected = CreateClassWithDifferentPropertiesClassDefinition(); var actual = classReflector.GetMetadata(null); Assert.That(actual, Is.Not.Null); _classDefinitionChecker.Check(expected, actual); _endPointDefinitionChecker.Check(expected.MyRelationEndPointDefinitions, actual.MyRelationEndPointDefinitions, false); }
private void CheckEndPointDefinitions(RelationDefinition expectedRelationDefinition, RelationDefinition actualRelationDefinition) { foreach (IRelationEndPointDefinition expectedEndPointDefinition in expectedRelationDefinition.EndPointDefinitions) { IRelationEndPointDefinition actualEndPointDefinition = actualRelationDefinition.GetEndPointDefinition( expectedEndPointDefinition.ClassDefinition.ID, expectedEndPointDefinition.PropertyName); Assert.IsNotNull( actualEndPointDefinition, "End point definition was not found (relation definition: '{0}', class: '{1}', property name: '{2}').", expectedRelationDefinition.ID, expectedEndPointDefinition.ClassDefinition.ID, expectedEndPointDefinition.PropertyName); var endPointDefinitionChecker = new RelationEndPointDefinitionChecker(); endPointDefinitionChecker.Check(expectedEndPointDefinition, actualEndPointDefinition, true); Assert.AreSame( actualRelationDefinition, actualEndPointDefinition.RelationDefinition, "End point definition does not reference the correct relation definition (relation definition: '{0}', class: '{1}', property name: '{2}').", actualRelationDefinition.ID, actualEndPointDefinition.ClassDefinition.ID, actualEndPointDefinition.PropertyName); } }
public void CheckRelationEndPoints(IEnumerable <ClassDefinition> expectedDefinitions, IDictionary <Type, ClassDefinition> actualDefinitions) { ArgumentUtility.CheckNotNull("expectedDefinitions", expectedDefinitions); ArgumentUtility.CheckNotNull("actualDefinitions", actualDefinitions); foreach (var expectedDefinition in expectedDefinitions) { var actualDefinition = actualDefinitions[expectedDefinition.ClassType]; var endPointDefinitionChecker = new RelationEndPointDefinitionChecker(); endPointDefinitionChecker.Check(expectedDefinition.MyRelationEndPointDefinitions, actualDefinition.MyRelationEndPointDefinitions, true); } }