コード例 #1
0
        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));
        }
コード例 #2
0
        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))));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }