public void WhenCircularManyToManyDictionaryThenApplyColumnNameByPropertyEntityClass()
        {
            var orm = new Mock<IDomainInspector>();
            orm.Setup(x => x.IsEntity(It.Is<Type>(t => t == typeof(Human)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(Human)), It.Is<Type>(t => t == typeof(Human)))).Returns(true);

            var pattern = new ManyToManyColumnApplier(orm.Object);
            var path = new PropertyPath(null, ForClass<Human>.Property(x => x.Family));
            var mayToManyMapper = new Mock<IManyToManyMapper>();

            pattern.Apply(path, mayToManyMapper.Object);

            mayToManyMapper.Verify(x => x.Column(It.Is<string>(columnName => columnName == "FamilyHumanId")));
        }
Пример #2
0
        public void WhenManyToManyDictionaryThenApplyColumnNameByEntityClass()
        {
            var orm = new Mock <IDomainInspector>();

            orm.Setup(x => x.IsEntity(It.Is <Type>(t => t == typeof(MyClass) || t == typeof(MyBidirect)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is <Type>(t => t == typeof(MyClass)), It.Is <Type>(t => t == typeof(MyBidirect)))).Returns(true);

            var pattern         = new ManyToManyColumnApplier(orm.Object);
            var path            = new PropertyPath(null, ForClass <MyClass> .Property(x => x.MapValue));
            var mayToManyMapper = new Mock <IManyToManyMapper>();

            pattern.Apply(path, mayToManyMapper.Object);

            mayToManyMapper.Verify(x => x.Column(It.Is <string>(columnName => columnName == "MyBidirectId")));
        }
Пример #3
0
        public void WhenCircularManyToManyDictionaryThenApplyColumnNameByPropertyEntityClass()
        {
            var orm = new Mock <IDomainInspector>();

            orm.Setup(x => x.IsEntity(It.Is <Type>(t => t == typeof(Human)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is <Type>(t => t == typeof(Human)), It.Is <Type>(t => t == typeof(Human)))).Returns(true);

            var pattern         = new ManyToManyColumnApplier(orm.Object);
            var path            = new PropertyPath(null, ForClass <Human> .Property(x => x.Family));
            var mayToManyMapper = new Mock <IManyToManyMapper>();

            pattern.Apply(path, mayToManyMapper.Object);

            mayToManyMapper.Verify(x => x.Column(It.Is <string>(columnName => columnName == "FamilyHumanId")));
        }
        public void WhenCircularManyToManyCollectionInsideComponentThenApplyColumnNameByPropertyPathEntityClass()
        {
            var orm = new Mock<IDomainInspector>();
            orm.Setup(x => x.IsEntity(It.Is<Type>(t => t == typeof(Human)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(Address)), It.Is<Type>(t => t == typeof(Human)))).Returns(true);

            var pattern = new ManyToManyColumnApplier(orm.Object);

            var pathEntity = new PropertyPath(null, ForClass<Human>.Property(x => x.Address));
            var path = new PropertyPath(pathEntity, ForClass<Address>.Property(x => x.Persons));
            var mayToManyMapper = new Mock<IManyToManyMapper>();

            pattern.Apply(path, mayToManyMapper.Object);

            mayToManyMapper.Verify(x => x.Column(It.Is<string>(columnName => columnName == "AddressPersonsHumanId")));
        }
Пример #5
0
        public void WhenCircularManyToManyCollectionInsideComponentThenApplyColumnNameByPropertyPathEntityClass()
        {
            var orm = new Mock <IDomainInspector>();

            orm.Setup(x => x.IsEntity(It.Is <Type>(t => t == typeof(Human)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is <Type>(t => t == typeof(Address)), It.Is <Type>(t => t == typeof(Human)))).Returns(true);

            var pattern = new ManyToManyColumnApplier(orm.Object);

            var pathEntity      = new PropertyPath(null, ForClass <Human> .Property(x => x.Address));
            var path            = new PropertyPath(pathEntity, ForClass <Address> .Property(x => x.Persons));
            var mayToManyMapper = new Mock <IManyToManyMapper>();

            pattern.Apply(path, mayToManyMapper.Object);

            mayToManyMapper.Verify(x => x.Column(It.Is <string>(columnName => columnName == "AddressPersonsHumanId")));
        }
        public void WhenManyToManyBidirectionalThenApplyColumnNameByEntityClass()
        {
            var orm = new Mock<IDomainInspector>();
            orm.Setup(x => x.IsEntity(It.Is<Type>(t => t == typeof(MyClass) || t == typeof(MyBidirect)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(MyClass)), It.Is<Type>(t => t == typeof(MyBidirect)))).Returns(true);
            orm.Setup(x => x.IsManyToMany(It.Is<Type>(t => t == typeof(MyBidirect)), It.Is<Type>(t => t == typeof(MyClass)))).Returns(true);

            var pattern = new ManyToManyColumnApplier(orm.Object);
            var path = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyBidirects));
            var mayToManyMapper = new Mock<IManyToManyMapper>();

            pattern.Apply(path, mayToManyMapper.Object);

            mayToManyMapper.Verify(x => x.Column(It.Is<string>(columnName => columnName == "MyBidirectId")));

            var bipath = new PropertyPath(null, ForClass<MyBidirect>.Property(x => x.MyClasses));
            var bimayToManyMapper = new Mock<IManyToManyMapper>();

            pattern.Apply(bipath, bimayToManyMapper.Object);

            bimayToManyMapper.Verify(x => x.Column(It.Is<string>(columnName => columnName == "MyClassId")));
        }