public void WhenRelationIsElementsInsideComponentThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);
            var path    = new PropertyPath(new PropertyPath(null, ForClass <MyClass> .Property(p => p.Components)), ForClass <MyComponent> .Property(p => p.Elements));

            pattern.Match(path).Should().Be.False();
        }
        public void WhenNoGenericCollectionThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);
            var path    = new PropertyPath(null, ForClass <MyClass> .Property(p => p.Something));

            pattern.Match(path).Should().Be.False();
        }
        public void WhenComponentsCollectionThenMatch()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);
            orm.Setup(x => x.IsComponent(typeof(MyComponent))).Returns(true);

            var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.Components));
            pattern.Match(path).Should().Be.True();
        }
        public void WhenRelationIsOneToManyInsideComponentThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);

            orm.Setup(x => x.IsOneToMany(It.Is <Type>(t => t == typeof(MyComponent)), It.Is <Type>(t => t == typeof(MyRelated)))).Returns(true);
            var path = new PropertyPath(new PropertyPath(null, ForClass <MyClass> .Property(p => p.Components)), ForClass <MyComponent> .Property(p => p.Relateds));

            pattern.Match(path).Should().Be.False();
        }
        public void WhenComponentsCollectionInsideComponentThenMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);

            orm.Setup(x => x.IsComponent(typeof(MyComponent))).Returns(true);
            var path = new PropertyPath(new PropertyPath(null, ForClass <MyClass> .Property(p => p.Component)), ForClass <MyComponent> .Property(p => p.Components));

            pattern.Match(path).Should().Be.True();
        }
        public void WhenCollectionIsInPlainEntityThenApplyClassNamePropertyName()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);
            orm.Setup(x => x.IsComponent(typeof(MyComponent))).Returns(true);

            var mapper = new Mock<ICollectionPropertiesMapper>();
            var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.Components));

            pattern.Match(path).Should().Be.True();
            pattern.Apply(path, mapper.Object);
            mapper.Verify(km => km.Table(It.Is<string>(s => s == "MyClassComponents")));
        }
        public void WhenCollectionIsInPlainEntityThenApplyClassNamePropertyName()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);

            orm.Setup(x => x.IsComponent(typeof(MyComponent))).Returns(true);

            var mapper = new Mock <ICollectionPropertiesMapper>();
            var path   = new PropertyPath(null, ForClass <MyClass> .Property(p => p.Components));

            pattern.Match(path).Should().Be.True();
            pattern.Apply(path, mapper.Object);
            mapper.Verify(km => km.Table(It.Is <string>(s => s == "MyClassComponents")));
        }
        public void WhenRelationIsElementsInsideComponentThenNoMatch()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);
            var path = new PropertyPath(new PropertyPath(null, ForClass<MyClass>.Property(p => p.Components)), ForClass<MyComponent>.Property(p => p.Elements));

            pattern.Match(path).Should().Be.False();
        }
        public void WhenNoGenericCollectionThenNoMatch()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);
            var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.Something));

            pattern.Match(path).Should().Be.False();
        }
        public void WhenRelationIsOneToManyThenNoMatch()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new CollectionOfComponentsTableApplier(orm.Object);
            orm.Setup(x => x.IsOneToMany(It.Is<Type>(t => t == typeof(MyClass)), It.Is<Type>(t => t == typeof(MyRelated)))).Returns(true);
            var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.Relateds));

            pattern.Match(path).Should().Be.False();
        }