public void WhenParentChildThenApplyPropertyNameIdOfChild()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new OneToManyKeyColumnApplier(orm.Object);
            orm.Setup(x => x.IsOneToMany(It.Is<Type>(t => t == typeof(Parent)), It.Is<Type>(t => t == typeof(Child)))).Returns(true);

            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<Parent>.Property(p => p.Children));

            pattern.Apply(path, mapper.Object);
            keyMapper.Verify(km => km.Column(It.Is<string>(s => s == "MyParentId")));
        }
Esempio n. 2
0
        public void WhenParentChildThenApplyPropertyNameIdOfChildInSeconfRelation()
        {
            Mock <IDomainInspector> orm = GetOrmMock();
            var pattern = new OneToManyKeyColumnApplier(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 <Team> .Property(p => p.MatchesOnRoad));

            pattern.Apply(path, mapper.Object);
            keyMapper.Verify(km => km.Column(It.Is <string>(s => s == "RoadTeamId")));
        }
Esempio n. 3
0
        public void WhenParentChildThenApplyPropertyNameIdOfChild()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new OneToManyKeyColumnApplier(orm.Object);

            orm.Setup(x => x.IsOneToMany(It.Is <Type>(t => t == typeof(Parent)), It.Is <Type>(t => t == typeof(Child)))).Returns(true);

            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 <Parent> .Property(p => p.Children));

            pattern.Apply(path, mapper.Object);
            keyMapper.Verify(km => km.Column(It.Is <string>(s => s == "MyParentId")));
        }
Esempio n. 4
0
        public void WhenRelationIsOneToManyForMapValueThenApplyClassNameId()
        {
            var orm     = new Mock <IDomainInspector>();
            var pattern = new OneToManyKeyColumnApplier(orm.Object);

            orm.Setup(x => x.IsOneToMany(It.Is <Type>(t => t == typeof(MyClass)), It.Is <Type>(t => t == typeof(MyRelated)))).Returns(true);

            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.Map));

            pattern.Apply(path, mapper.Object);
            keyMapper.Verify(km => km.Column(It.Is <string>(s => s == "MyClassId")));
        }
        public void WhenRelationIsOneToManyForMapValueThenApplyClassNameId()
        {
            var orm = new Mock<IDomainInspector>();
            var pattern = new OneToManyKeyColumnApplier(orm.Object);
            orm.Setup(x => x.IsOneToMany(It.Is<Type>(t => t == typeof(MyClass)), It.Is<Type>(t => t == typeof(MyRelated)))).Returns(true);

            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.Map));

            pattern.Apply(path, mapper.Object);
            keyMapper.Verify(km => km.Column(It.Is<string>(s => s == "MyClassId")));
        }