Пример #1
0
        public void WhenExplicitlyDeclaredThenEachCollectionMapToItsCorrectParentPropertyIntegration()
        {
            var orm = new ObjectRelationalMapper();

            orm.TablePerClass <Team>();
            orm.TablePerClass <Match>();
            orm.Bidirectional <Team, Match>(t => t.MatchesAtHome, m => m.HomeTeam);
            orm.Bidirectional <Match, Team>(m => m.RoadTeam, t => t.MatchesOnRoad);

            HbmMapping mapping = GetMapping(orm);

            VerifyBagsHasTheCorrectKey(mapping);
        }
Пример #2
0
        public void WhenDoubleRegistrationThenNotThrows()
        {
            var orm = new ObjectRelationalMapper();

            orm.Bidirectional <B, A>(b => b.Generic, a => a.Bag);
            orm.Executing(o => o.Bidirectional <B, A>(b => b.Generic, a => a.Bag)).NotThrows();
        }
Пример #3
0
        public void WhenAmbiguousRegistrationThenThrows()
        {
            var orm = new ObjectRelationalMapper();

            orm.Bidirectional <A, B>(a => a.Bag, b => b.A);
            orm.Executing(o => o.Bidirectional <A, B>(a => a.Bag, b => b.Generic)).Throws <MappingException>()
            .And.ValueOf.Message.ToLowerInvariant().Should().Contain("ambiguous");
        }
Пример #4
0
        public void WhenRegisterCollectionToCollectionThenFindRelation()
        {
            var orm = new ObjectRelationalMapper();

            orm.Bidirectional <B, A>(b => b.Generic, a => a.Bag);

            orm.GetBidirectionalMember(typeof(A), ForClass <A> .Property(x => x.Bag), typeof(B)).Should().Be(ForClass <B> .Property(x => x.Generic));
            orm.GetBidirectionalMember(typeof(B), ForClass <B> .Property(x => x.Generic), typeof(A)).Should().Be(ForClass <A> .Property(x => x.Bag));
        }
Пример #5
0
        public void IntegrationWithObjectRelationalMapper()
        {
            var orm = new ObjectRelationalMapper();

            orm.TablePerClass <MyClass>();
            orm.Bidirectional <MyClass, Component>(mc => mc.Components, c => c.Owner);
            HbmMapping mapping = GetMapping(orm);

            VerifyMappingContainsClassWithComponentAndParent(mapping);
        }
Пример #6
0
        public void IntegrationWithObjectRelationalMapperRegisteringTheInverse()
        {
            var orm = new ObjectRelationalMapper();

            orm.TablePerClass <MyClass>();
            orm.Bidirectional <Component, MyClass>(component => component.Owner, myClass => myClass.Components);
            HbmMapping mapping = GetMapping(orm);

            VerifyMappingContainsClassWithComponentAndParent(mapping);
        }