protected RelationEndPointDefinition GetRelationEndPointDefinition <TSource, TRelated> (Expression <Func <TSource, TRelated> > propertyAccessExpression) { var typeDefinition = MappingConfiguration.GetTypeDefinition(typeof(TSource)); var propertyInfoAdapter = PropertyInfoAdapter.Create(NormalizingMemberInfoFromExpressionUtility.GetProperty(propertyAccessExpression)); return((RelationEndPointDefinition)typeDefinition.ResolveRelationEndPoint(propertyInfoAdapter)); }
public void GetTypeDefinition_ValueNotFound() { StubMockMappingLoader(_emptyClassDefinitions, _emptyRelationDefinitions); var persistenceModelLoaderStub = CreatePersistenceModelLoaderStub(); _mockRepository.ReplayAll(); var configuration = new MappingConfiguration(_mockMappingLoader, persistenceModelLoaderStub); Assert.That( () => configuration.GetTypeDefinition(typeof(DomainObject)), Throws.Exception.TypeOf <MappingException>() .And.Message.EqualTo(String.Format("Mapping does not contain class '{0}'.", typeof(DomainObject)))); }
public void GetTypeDefinition_ValueNotFound_CustomException() { StubMockMappingLoader(_emptyClassDefinitions, _emptyRelationDefinitions); var persistenceModelLoaderStub = CreatePersistenceModelLoaderStub(); _mockRepository.ReplayAll(); var configuration = new MappingConfiguration(_mockMappingLoader, persistenceModelLoaderStub); Assert.That( () => configuration.GetTypeDefinition(typeof(DomainObject), t => new ApplicationException(t.Name)), Throws.Exception.TypeOf <ApplicationException> () .And.Message.EqualTo(typeof(DomainObject).Name)); }
public void GetTypeDefinition_ValueFound() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(RelationEndPointPropertyClass)); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection()); classDefinition.SetDerivedClasses(Enumerable.Empty <ClassDefinition>()); StubMockMappingLoader(new[] { classDefinition }, _emptyRelationDefinitions); var persistenceModelLoaderStub = CreatePersistenceModelLoaderStub(); _mockRepository.ReplayAll(); var configuration = new MappingConfiguration(_mockMappingLoader, persistenceModelLoaderStub); Assert.That(configuration.GetTypeDefinition(typeof(RelationEndPointPropertyClass)), Is.SameAs(classDefinition)); }