public void InvokeDirectMethods()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionElementCustomizer(propertyPath, customizersHolder);
            var elementMapper = new Mock<IElementMapper>();

            customizer.Length(10);
            customizer.Precision(5);
            customizer.Scale(2);
            customizer.NotNullable(true);
            customizer.Unique(true);
            customizer.Column("pizza");
            customizer.Type(NHibernateUtil.StringClob);
            customizer.Type<MyUserType>();
            var parameters = new {something= 10};
            customizer.Type<MyUserType>(parameters);
            customizer.Type(typeof(MyUserType), parameters);

            customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object);

            elementMapper.Verify(x => x.Length(It.Is<int>(v => v == 10)), Times.Once());
            elementMapper.Verify(x => x.Precision(It.Is<short>(v => v == 5)), Times.Once());
            elementMapper.Verify(x => x.Scale(It.Is<short>(v => v == 2)), Times.Once());
            elementMapper.Verify(x => x.Unique(It.Is<bool>(v => v)), Times.Once());
            elementMapper.Verify(x => x.NotNullable(It.Is<bool>(v => v)), Times.Once());
            elementMapper.Verify(x => x.Column(It.Is<string>(v => v == "pizza")), Times.Once());
            elementMapper.Verify(x => x.Type(It.Is<IType>(v => v.GetType() == NHibernateUtil.StringClob.GetType())), Times.Once());
            elementMapper.Verify(x => x.Type<MyUserType>(), Times.Once());
            elementMapper.Verify(x => x.Type<MyUserType>(It.Is<object>(v=> v == parameters)), Times.Once());
            elementMapper.Verify(x => x.Type(It.Is<Type>(v=> v == typeof(MyUserType)), It.Is<object>(v => v == parameters)), Times.Once());
        }
        public void InvokeCustomizerOfCollectionElementRelation()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var elementMapper = new Mock<IElementMapper>();

            customizersHolder.AddCustomizer(propertyPath, (IElementMapper x) => x.Length(10));
            customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object);

            elementMapper.Verify(x => x.Length(It.Is<int>(v => v == 10)), Times.Once());
        }
        public void InvokeCustomizerOfCollectionOneToManyRelation()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var elementMapper = new Mock<IOneToManyMapper>();

            customizersHolder.AddCustomizer(propertyPath, (IOneToManyMapper x) => x.NotFound(NotFoundMode.Ignore));
            customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object);

            elementMapper.Verify(x => x.NotFound(It.Is<NotFoundMode>(v => v == NotFoundMode.Ignore)), Times.Once());
        }
        public void InvokeCustomizerOfDictionaryKeyManyToManyRelation()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyDictionary));
            var customizersHolder = new CustomizersHolder();
            var elementMapper = new Mock<IMapKeyManyToManyMapper>();

            customizersHolder.AddCustomizer(propertyPath, (IMapKeyManyToManyMapper x) => x.Column("pizza"));
            customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object);

            elementMapper.Verify(x => x.Column(It.Is<string>(v => v == "pizza")), Times.Once());
        }
        public void InvokingCustomizerOnBagThenInvokeCollectionPropertiesCustomizer()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var concreteCollectionMapper = new Mock<IBagPropertiesMapper>();

            customizersHolder.AddCustomizer(propertyPath, (ICollectionPropertiesMapper x) => x.BatchSize(10));
            customizersHolder.InvokeCustomizers(propertyPath, concreteCollectionMapper.Object);

            concreteCollectionMapper.Verify(x => x.BatchSize(It.Is<int>(v => v == 10)), Times.Once());
        }
        public void InvokeSetOfSchemaAction()
        {
            var customizersHolder = new CustomizersHolder();
            var customizer = new ClassCustomizer<MyClass>(customizersHolder);
            var classMapper = new Mock<IClassAttributesMapper>();

            customizer.SchemaAction(SchemaAction.None);
            customizersHolder.InvokeCustomizers(typeof(MyClass), classMapper.Object);

            classMapper.Verify(x => x.SchemaAction(SchemaAction.None));
        }
		public void MergeShouldMergeCollectionPropertiesMapper()
		{
			var emptyHolder = new CustomizersHolder();
			var holder = new CustomizersHolder();
			var called = false;

			holder.AddCustomizer(propertyPath, (ICollectionPropertiesMapper x) => called = true);
			emptyHolder.Merge(holder);
			emptyHolder.InvokeCustomizers(propertyPath, (IBagPropertiesMapper)null);

			Assert.That(called, Is.True);
		}
		public void MergeShouldMergeElementMapper()
		{
			var emptyHolder = new CustomizersHolder();
			var holder = new CustomizersHolder();
			var called = false;

			holder.AddCustomizer(propertyPath, (IElementMapper x) => called = true);
			emptyHolder.Merge(holder);
			emptyHolder.InvokeCustomizers(propertyPath, (IElementMapper)null);

			called.Should().Be.True();
		}
        public void InvokeFilterMapping()
        {
            var customizersHolder = new CustomizersHolder();
            var customizer = new ClassCustomizer<MyClass>(customizersHolder);
            var classMapper = new Mock<IClassAttributesMapper>();
            var filterMapper = new Mock<IFilterMapper>();
            classMapper.Setup(x => x.Filter(It.IsAny<string>(), It.IsAny<Action<IFilterMapper>>())).Callback<string, Action<IFilterMapper>>(
                (name, x) => x.Invoke(filterMapper.Object));

            customizer.Filter("pizza",x => x.Condition("any condition"));
            customizersHolder.InvokeCustomizers(typeof(MyClass), classMapper.Object);

            filterMapper.Verify(x => x.Condition(It.Is<string>(v => v == "any condition")));
        }
        public void WhenRegisteredCustomizerForDictionaryThenCallElementMapperAction()
        {
            var orm = GetBaseMockedDomainInspector();
            orm.Setup(x => x.IsDictionary(It.Is<MemberInfo>(m => m == ForClass<Person>.Property(p => p.Farm)))).Returns(true);
            bool customizerInvoked = false;
            var propertyPath = new PropertyPath(null, ForClass<Person>.Property(p => p.Farm));
            var customizersHolder = new CustomizersHolder();
            customizersHolder.AddCustomizer(propertyPath, (IOneToManyMapper x) => customizerInvoked = true);

            var mapper = new Mapper(orm.Object, customizersHolder);
            mapper.CompileMappingFor(new[] { typeof(Person) });

            customizerInvoked.Should().Be.True();
        }
        public void InvokeColumnCustomizer()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionElementCustomizer(propertyPath, customizersHolder);
            var elementMapper = new Mock<IElementMapper>();
            var columnMapper = new Mock<IColumnMapper>();
            elementMapper.Setup(x => x.Column(It.IsAny<Action<IColumnMapper>>())).Callback<Action<IColumnMapper>>(
                x => x.Invoke(columnMapper.Object));

            customizer.Column(c => c.SqlType("VARCHAR(100)"));
            customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object);

            columnMapper.Verify(x => x.SqlType(It.Is<string>(v => v == "VARCHAR(100)")));
        }
        public void InvokeColumn()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionKeyCustomizer<MyClass>(propertyPath, customizersHolder);
            var collectionMapper = new Mock<ISetPropertiesMapper>();
            var keyMapper = new Mock<IKeyMapper>();
            collectionMapper.Setup(x => x.Key(It.IsAny<Action<IKeyMapper>>())).Callback<Action<IKeyMapper>>(
                x => x.Invoke(keyMapper.Object));

            customizer.Column("pizza");
            customizersHolder.InvokeCustomizers(propertyPath, collectionMapper.Object);

            keyMapper.Verify(x => x.Column(It.Is<string>(str => str == "pizza")), Times.Once());
        }
        public void InvokeOnDelete()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionKeyCustomizer<MyClass>(propertyPath, customizersHolder);
            var collectionMapper = new Mock<ISetPropertiesMapper>();
            var keyMapper = new Mock<IKeyMapper>();
            collectionMapper.Setup(x => x.Key(It.IsAny<Action<IKeyMapper>>())).Callback<Action<IKeyMapper>>(
                x => x.Invoke(keyMapper.Object));

            customizer.OnDelete(OnDeleteAction.Cascade);
            customizersHolder.InvokeCustomizers(propertyPath, collectionMapper.Object);

            keyMapper.Verify(x => x.OnDelete(It.Is<OnDeleteAction>(v => v == OnDeleteAction.Cascade)), Times.Once());
        }
        public void InvokeIndex()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new ListPropertiesCustomizer<MyClass, int>(propertyPath, customizersHolder);
            var collectionMapper = new Mock<IListPropertiesMapper>();
            var listIndexMapper = new Mock<IListIndexMapper>();
            collectionMapper.Setup(x => x.Index(It.IsAny<Action<IListIndexMapper>>())).Callback<Action<IListIndexMapper>>(
                x => x.Invoke(listIndexMapper.Object));

            customizer.Index(x => x.Base(1));
            customizersHolder.InvokeCustomizers(propertyPath, collectionMapper.Object);

            listIndexMapper.Verify(x => x.Base(It.Is<int>(v => v == 1)));
        }
        public void InvokePropertyRef()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionKeyCustomizer<MyClass>(propertyPath, customizersHolder);
            var collectionMapper = new Mock<ISetPropertiesMapper>();
            var keyMapper = new Mock<IKeyMapper>();
            collectionMapper.Setup(x => x.Key(It.IsAny<Action<IKeyMapper>>())).Callback<Action<IKeyMapper>>(
                x => x.Invoke(keyMapper.Object));

            customizer.PropertyRef(x=> x.AProp);
            customizersHolder.InvokeCustomizers(propertyPath, collectionMapper.Object);

            keyMapper.Verify(x => x.PropertyRef(It.Is<MemberInfo>(v => v == ForClass<MyClass>.Property(p=> p.AProp))), Times.Once());
        }
        public void InvokeCache()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionPropertiesCustomizer<MyClass, MyEle>(propertyPath, customizersHolder);
            var collectionMapper = new Mock<ISetPropertiesMapper>();
            var cacheMapper = new Mock<ICacheMapper>();
            collectionMapper.Setup(x => x.Cache(It.IsAny<Action<ICacheMapper>>())).Callback<Action<ICacheMapper>>(
                x => x.Invoke(cacheMapper.Object));

            customizer.Cache(x=> x.Region("static"));
            customizersHolder.InvokeCustomizers(propertyPath, collectionMapper.Object);

            cacheMapper.Verify(x => x.Region(It.Is<string>(v => v == "static")));
        }
        public void InvokeDirectMethods()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new OneToManyCustomizer(propertyPath, customizersHolder);
            var elementMapper = new Mock<IOneToManyMapper>();

            customizer.Class(typeof (Related));
            customizer.EntityName("something");
            customizer.NotFound(NotFoundMode.Ignore);

            customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object);

            elementMapper.Verify(x => x.Class(It.Is<Type>(v => v == typeof (Related))), Times.Once());
            elementMapper.Verify(x => x.EntityName(It.Is<string>(v => v == "something")), Times.Once());
            elementMapper.Verify(x => x.NotFound(It.Is<NotFoundMode>(v => v == NotFoundMode.Ignore)), Times.Once());
        }
        public void InvokeDirectMethods()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionPropertiesCustomizer<MyClass, MyEle>(propertyPath, customizersHolder);
            var collectionMapper = new Mock<ISetPropertiesMapper>();

            customizer.Inverse(true);
            customizer.Mutable(true);
            customizer.Where("aa");
            customizer.BatchSize(10);
            customizer.Lazy(CollectionLazy.Extra);
            customizer.OrderBy(x=>x.Name);
            customizer.Sort();
            customizer.Sort<object>();
            customizer.Cascade(Cascade.DeleteOrphans);
            customizer.Type<FakeUserCollectionType>();
            customizer.Type(typeof(FakeUserCollectionType));
            customizer.Table("table");
            customizer.Catalog("catalog");
            customizer.Schema("schema");
            customizer.OptimisticLock(true);
            customizer.Access(Accessor.NoSetter);
            customizer.Access(typeof(object)); // <== only to check the call

            customizersHolder.InvokeCustomizers(propertyPath, collectionMapper.Object);

            collectionMapper.Verify(x => x.Inverse(It.Is<bool>(v => v)), Times.Once());
            collectionMapper.Verify(x => x.Mutable(It.Is<bool>(v => v)), Times.Once());
            collectionMapper.Verify(x => x.Where(It.Is<string>(v => v == "aa")), Times.Once());
            collectionMapper.Verify(x => x.BatchSize(It.Is<int>(v => v == 10)), Times.Once());
            collectionMapper.Verify(x => x.Lazy(It.Is<CollectionLazy>(v => v == CollectionLazy.Extra)), Times.Once());
            collectionMapper.Verify(x => x.OrderBy(It.Is<MemberInfo>(v => v == ForClass<MyEle>.Property(p=>p.Name))), Times.Once());
            collectionMapper.Verify(x => x.Sort(), Times.Once());
            collectionMapper.Verify(x => x.Sort<object>(), Times.Once());
            collectionMapper.Verify(x => x.Cascade(It.Is<Cascade>(v => v == Cascade.DeleteOrphans)), Times.Once());
            collectionMapper.Verify(x => x.Type<FakeUserCollectionType>(), Times.Once());
            collectionMapper.Verify(x => x.Type(It.Is<Type>(v => v == typeof(FakeUserCollectionType))), Times.Once());
            collectionMapper.Verify(x => x.Table(It.Is<string>(v => v == "table")), Times.Once());
            collectionMapper.Verify(x => x.Catalog(It.Is<string>(v => v == "catalog")), Times.Once());
            collectionMapper.Verify(x => x.Schema(It.Is<string>(v => v == "schema")), Times.Once());
            collectionMapper.Verify(x => x.OptimisticLock(It.Is<bool>(v => v)), Times.Once());
            collectionMapper.Verify(x => x.Access(It.Is<Accessor>(v => v == Accessor.NoSetter)), Times.Once());
            collectionMapper.Verify(x => x.Access(It.IsAny<Type>()), Times.Once());
        }
        public void InvokeDirectMethods()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.Dictionary));
            var customizersHolder = new CustomizersHolder();
            var customizer = new MapKeyCustomizer(propertyPath, customizersHolder);
            var elementMapper = new Mock<IMapKeyMapper>();

            customizer.Type(typeof(MyUserType));
            customizer.Type<MyUserType>();
            customizer.Type(NHibernateUtil.String);
            customizer.Length(10);
            customizer.Column("pizza");

            customizersHolder.InvokeCustomizers(propertyPath, elementMapper.Object);

            elementMapper.Verify(x => x.Type(It.Is<Type>(v => v == typeof(MyUserType))), Times.Once());
            elementMapper.Verify(x => x.Type<MyUserType>(), Times.Once());
            elementMapper.Verify(x => x.Type(It.Is<IType>(v => v.GetType() == NHibernateUtil.String.GetType())), Times.Once());
            elementMapper.Verify(x => x.Length(It.Is<int>(v => v == 10)), Times.Once());
            elementMapper.Verify(x => x.Column(It.Is<string>(v => v == "pizza")), Times.Once());
        }
Exemple #20
0
 public void Lazy(bool value)
 {
     CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.Lazy(value));
 }
Exemple #21
0
 public void BatchSize(int value)
 {
     CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.BatchSize(value));
 }
Exemple #22
0
 public void Persister <T>() where T : IEntityPersister
 {
     CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.Persister <T>());
 }
Exemple #23
0
 public void Access(System.Type accessorType)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (IDynamicComponentAttributesMapper m) => m.Access(accessorType));
 }
Exemple #24
0
 public void OrderBy(string sqlOrderByClause)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.OrderBy(sqlOrderByClause));
 }
		public void MergeShouldMergeDynamicComponentAttributesMapper()
		{
			var emptyHolder = new CustomizersHolder();
			var holder = new CustomizersHolder();
			var called = false;

			holder.AddCustomizer(propertyPath, (IDynamicComponentAttributesMapper x) => called = true);
			emptyHolder.Merge(holder);
			emptyHolder.InvokeCustomizers(propertyPath, (IDynamicComponentAttributesMapper)null);

			called.Should().Be.True();
		}
Exemple #26
0
 public void Fetch(CollectionFetchMode fetchMode)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Fetch(fetchMode));
 }
Exemple #27
0
 public void Filter(string filterName, Action <IFilterMapper> filterMapping)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Filter(filterName, filterMapping));
 }
Exemple #28
0
 public void Cache(Action <ICacheMapper> cacheMapping)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Cache(cacheMapping));
 }
Exemple #29
0
 public void Schema(string schemaName)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Schema(schemaName));
 }
Exemple #30
0
 public void Catalog(string catalogName)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Catalog(catalogName));
 }
Exemple #31
0
 public void Unique(bool unique)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (IDynamicComponentAttributesMapper m) => m.Unique(unique));
 }
Exemple #32
0
 public void Persister <TPersister>() where TPersister : ICollectionPersister
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Persister(typeof(TPersister)));
 }
		public void WhenMergeWithNullThenNotThrow()
		{
			var emptyHolder = new CustomizersHolder();
			emptyHolder.Executing(x=> x.Merge(null)).NotThrows();
		}
Exemple #34
0
 public void Access(Accessor accessor)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Access(accessor));
 }
Exemple #35
0
 public void Insert(bool consideredInInsertQuery)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (IDynamicComponentAttributesMapper m) => m.Insert(consideredInInsertQuery));
 }
Exemple #36
0
 public void OptimisticLock(bool takeInConsiderationForOptimisticLock)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (IDynamicComponentAttributesMapper m) => m.OptimisticLock(takeInConsiderationForOptimisticLock));
 }
Exemple #37
0
 public void Sort()
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Sort());
 }
		public void MergeShouldMergeMapKeyManyToManyMapper()
		{
			var emptyHolder = new CustomizersHolder();
			var holder = new CustomizersHolder();
			var called = false;

			holder.AddCustomizer(propertyPath, (IMapKeyManyToManyMapper x) => called = true);
			emptyHolder.Merge(holder);
			emptyHolder.InvokeCustomizers(propertyPath, (IMapKeyManyToManyMapper)null);

			Assert.That(called, Is.True);
		}
Exemple #39
0
 public void Synchronize(params string[] table)
 {
     CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.Synchronize(table));
 }
Exemple #40
0
 public void Loader(string namedQueryReference)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Loader(namedQueryReference));
 }
Exemple #41
0
 public void SelectBeforeUpdate(bool value)
 {
     CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.SelectBeforeUpdate(value));
 }
Exemple #42
0
 public void Subselect(string sql)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Subselect(sql));
 }
Exemple #43
0
 public void DynamicInsert(bool value)
 {
     CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.DynamicInsert(value));
 }
Exemple #44
0
 public void Mutable(bool value)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Mutable(value));
 }
Exemple #45
0
 public void Proxy(System.Type proxy)
 {
     CustomizersHolder.AddCustomizer(typeof(TEntity), (ISubclassMapper m) => m.Proxy(proxy));
 }
Exemple #46
0
 public void Where(string sqlWhereClause)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Where(sqlWhereClause));
 }
		public void MergeShouldMergeUnionSubclassAttributesMapper()
		{
			var emptyHolder = new CustomizersHolder();
			var holder = new CustomizersHolder();
			var called = false;

			holder.AddCustomizer(typeof(MyClass), (IUnionSubclassAttributesMapper x) => called = true);
			emptyHolder.Merge(holder);
			emptyHolder.InvokeCustomizers(typeof(MyClass), (IUnionSubclassAttributesMapper)null);

			Assert.That(called, Is.True);
		}
Exemple #48
0
 public void BatchSize(int value)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.BatchSize(value));
 }
        public void InvokeFilter()
        {
            var propertyPath = new PropertyPath(null, ForClass<MyClass>.Property(x => x.MyCollection));
            var customizersHolder = new CustomizersHolder();
            var customizer = new CollectionPropertiesCustomizer<MyClass, MyEle>(propertyPath, customizersHolder);
            var collectionMapper = new Mock<ISetPropertiesMapper>();
            var filterMapper = new Mock<IFilterMapper>();
            collectionMapper.Setup(x => x.Filter(It.IsAny<string>(), It.IsAny<Action<IFilterMapper>>())).Callback<string, Action<IFilterMapper>>(
                (fn, x) => x.Invoke(filterMapper.Object));

            customizer.Filter("myfilter", x => x.Condition("condition"));
            customizersHolder.InvokeCustomizers(propertyPath, collectionMapper.Object);

            filterMapper.Verify(x => x.Condition(It.Is<string>(v => v == "condition")));
        }
Exemple #50
0
 public void Lazy(CollectionLazy collectionLazy)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Lazy(collectionLazy));
 }
		public void MergeShouldMergeComponentAttributesMapper()
		{
			var emptyHolder = new CustomizersHolder();
			var holder = new CustomizersHolder();
			var called = false;

			holder.AddCustomizer(typeof(MyClass), (IComponentAttributesMapper x) => called = true);
			emptyHolder.Merge(holder);
			emptyHolder.InvokeCustomizers(typeof(MyClass), (IComponentAttributesMapper)null);

			called.Should().Be.True();
		}
Exemple #52
0
        public void OrderBy <TProperty>(Expression <Func <TElement, TProperty> > property)
        {
            MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);

            CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.OrderBy(member));
        }
Exemple #53
0
 public void Access(System.Type accessorType)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.Access(accessorType));
 }
Exemple #54
0
 public void Update(bool consideredInUpdateQuery)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (IDynamicComponentAttributesMapper m) => m.Update(consideredInUpdateQuery));
 }
Exemple #55
0
 public void OptimisticLock(bool takeInConsiderationForOptimisticLock)
 {
     CustomizersHolder.AddCustomizer(PropertyPath, (ICollectionPropertiesMapper x) => x.OptimisticLock(takeInConsiderationForOptimisticLock));
 }
		public void WhenMergeWithNullThenNotThrow()
		{
			var emptyHolder = new CustomizersHolder();
			Assert.That(() => emptyHolder.Merge(null), Throws.Nothing);
		}