コード例 #1
0
        public void WhenRelationIsElementsInsideComponentThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsKeyColumnApplier(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();
        }
コード例 #2
0
        public void WhenNoGenericCollectionThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsKeyColumnApplier(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 CollectionOfComponentsKeyColumnApplier(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();
        }
コード例 #4
0
        public void WhenRelationIsOneToManyInsideComponentThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsKeyColumnApplier(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();
        }
コード例 #5
0
        public void WhenComponentsCollectionInsideComponentThenMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsKeyColumnApplier(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 WhenCollectionIsInPlainEntityThenApplyClassNameId()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new CollectionOfComponentsKeyColumnApplier(orm.Object);

            var mapper = new Mock<ICollectionPropertiesMapper>();
            var keyMapper = new Mock<IKeyMapper>();
            mapper.Setup(x => x.Key(It.IsAny<Action<IKeyMapper>>())).Callback<Action<IKeyMapper>>(
                x => x.Invoke(keyMapper.Object));
            var path = new PropertyPath(null, ForClass<MyClass>.Property(p => p.Components));

            pattern.Apply(path, mapper.Object);
            keyMapper.Verify(km => km.Column(It.Is<string>(s => s == "MyClassId")));
        }
コード例 #7
0
        public void WhenCollectionIsInPlainEntityThenApplyClassNameId()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfComponentsKeyColumnApplier(orm.Object);

            var mapper    = new Mock <ICollectionPropertiesMapper>();
            var keyMapper = new Mock <IKeyMapper>();

            mapper.Setup(x => x.Key(It.IsAny <Action <IKeyMapper> >())).Callback <Action <IKeyMapper> >(
                x => x.Invoke(keyMapper.Object));
            var path = new PropertyPath(null, ForClass <MyClass> .Property(p => p.Components));

            pattern.Apply(path, mapper.Object);
            keyMapper.Verify(km => km.Column(It.Is <string>(s => s == "MyClassId")));
        }
        public void WhenRelationIsElementsInsideComponentThenNoMatch()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new CollectionOfComponentsKeyColumnApplier(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 CollectionOfComponentsKeyColumnApplier(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 CollectionOfComponentsKeyColumnApplier(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();
        }