Пример #1
0
        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();
        }
Пример #2
0
        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();
        }
Пример #3
0
        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();
        }
Пример #4
0
        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();
        }
Пример #5
0
        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();
        }
Пример #6
0
        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();
        }
Пример #7
0
        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();
        }