public void WhenInterfaceOnParentThenMatch() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Node>(); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Match(ForClass <Node> .Property(x => x.SubNodes)).Should().Be.True(); }
public void WhenInterfaceOnParentAndPropertyExclusionOnImplThenNoMatch() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Node>(); orm.ExcludeProperty <Node>(x => x.ParentNode); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Match(ForClass <Node> .Property(x => x.SubNodes)).Should().Be.False(); }
public void WhenNoGenericThenNoMatch() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Parent>(); orm.TablePerClass <Child>(); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Match(ForClass <Parent> .Property(x => x.Whatever)).Should().Be.False(); }
public void WhenNullThenNoThrow() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Parent>(); orm.TablePerClass <Child>(); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Executing(p => p.Match(null)).NotThrows(); }
public void WhenInterfaceOnChildAndPropertyExclusionOnInterfaceThenNoMatch() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Parent>(); orm.TablePerClass <Child>(); orm.ExcludeProperty <IChild>(c => c.Parent); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Match(ForClass <Parent> .Property(x => x.Children)).Should().Be.False(); }
public void WhenNoPolymorphicThenNoMatch() { // using the concrete implementation of IDomainInspector this test is more like an integration-test but it is exactly what I need. var orm = new ObjectRelationalMapper(); orm.TablePerClass <Parent>(); orm.TablePerClass <Child>(); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); pattern.Match(ForClass <Parent> .Property(x => x.Children)).Should().Be.False(); }
public void WhenManyToManyShouldNotMatch() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <Contact>(); orm.TablePerClass <Company>(); orm.ManyToMany <Contact, Company>(); var pattern = new PolymorphismBidirectionalOneToManyMemberPattern(orm); MemberInfo memberInfo = ForClass <Contact> .Property(x => x.Companies); pattern.Match(memberInfo).Should().Be.False(); }