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); }
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(); }
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"); }
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)); }
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); }
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); }