예제 #1
0
        public void WhenNoGenericCollectionThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfElementsColumnApplier(orm.Object);
            var path    = new PropertyPath(null, ForClass <MyClass> .Property(p => p.Something));

            pattern.Match(path).Should().Be.False();
        }
예제 #2
0
        public void WhenCollectionOfElementsInsideComponentThenMatch()
        {
            var orm            = new Mock <IDomainInspector>();
            var pattern        = new CollectionOfElementsColumnApplier(orm.Object);
            var pathCollection = new PropertyPath(null, ForClass <MyComponent> .Property(p => p.Strings));

            pattern.Match(pathCollection).Should().Be.True();
        }
예제 #3
0
        public void WhenRelationIsManyToManyThenNoMatch()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfElementsColumnApplier(orm.Object);

            orm.Setup(x => x.IsManyToMany(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();
        }
예제 #4
0
        public void WhenCollectionOfElementsInsideEntityThenApplyPropertyNameElement()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new CollectionOfElementsColumnApplier(orm.Object);

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

            pattern.Apply(path, mapper.Object);
            mapper.Verify(elementMapper => elementMapper.Column(It.Is <string>(s => s == "StringsElement")));
        }
예제 #5
0
        public void WhenApplyThenCallInflector()
        {
            var orm       = new Mock <IDomainInspector>();
            var inflector = new Mock <IInflector>();

            inflector.Setup(i => i.Singularize("Addresses")).Returns("Address");
            var applier = new CollectionOfElementsColumnApplier(orm.Object, inflector.Object);
            var mapper  = new Mock <IElementMapper>();
            var path    = new PropertyPath(null, ForClass <Person> .Property(p => p.Addresses));

            applier.Apply(path, mapper.Object);

            mapper.Verify(m => m.Column("Address"));
        }