public void RelationDefinitionWithTypeNotFoundClassDefinition() { var classDefinition = new ClassDefinitionForUnresolvedRelationPropertyType( "Test", typeof(ClassOutOfInheritanceHierarchy), PropertyInfoAdapter.Create(typeof(DerivedValidationDomainObjectClass).GetProperty("Property"))); var endPoint = new VirtualRelationEndPointDefinition( classDefinition, "RelationProperty", false, CardinalityType.One, null, PropertyInfoAdapter.Create(typeof(DerivedValidationDomainObjectClass).GetProperty("Property"))); var relationDefinition = new RelationDefinition("ID", endPoint, endPoint); var validationResult = _validationRule.Validate(relationDefinition); var expectedMessage = "The relation property 'Property' has return type 'String', which is not a part of the mapping. " + "Relation properties must not point to classes above the inheritance root.\r\n\r\n" + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.DerivedValidationDomainObjectClass\r\n" + "Property: Property"; AssertMappingValidationResult(validationResult, false, expectedMessage); }
private ClassDefinition GetOppositeClassDefinition(IDictionary <Type, ClassDefinition> classDefinitions) { var type = ReflectionUtility.GetRelatedObjectTypeFromRelationProperty(PropertyInfo); var oppositeClassDefinition = classDefinitions.GetValueOrDefault(type); if (oppositeClassDefinition == null) { var notFoundClassDefinition = new ClassDefinitionForUnresolvedRelationPropertyType(type.Name, type, PropertyInfo); notFoundClassDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection()); notFoundClassDefinition.SetRelationEndPointDefinitions(new RelationEndPointDefinitionCollection()); return(notFoundClassDefinition); } return(oppositeClassDefinition); }