public void SetWhere() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Where("c > 10"); Assert.That(hbm.Where, Is.EqualTo("c > 10")); }
public void SetWhere() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Where("c > 10"); hbm.Where.Should().Be.EqualTo("c > 10"); }
public void WhenConfigureIdThenCallMapper() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Id(x => x.Column("catchMe")); Assert.That(hbm.collectionid.Columns.Single().name, Is.EqualTo("catchMe")); }
public void WhenConfigureIdThenCallMapper() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Id(x => x.Column("catchMe")); hbm.collectionid.Columns.Single().name.Should().Be("catchMe"); }
public virtual void IdBag(MemberInfo property, Action<IIdBagPropertiesMapper> collectionMapping, Action<ICollectionElementRelation> mapping) { var hbm = new HbmIdbag { name = property.Name }; System.Type collectionElementType = property.DetermineRequiredCollectionElementType(); collectionMapping(new IdBagMapper(container, collectionElementType, hbm)); mapping(new CollectionElementRelation(collectionElementType, MapDoc, rel => hbm.Item = rel)); AddProperty(hbm); }
public void SetMutable() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Mutable(true); hbm.Mutable.Should().Be.True(); mapper.Mutable(false); hbm.Mutable.Should().Be.False(); }
public void SetMutable() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Mutable(true); Assert.That(hbm.Mutable, Is.True); mapper.Mutable(false); Assert.That(hbm.Mutable, Is.False); }
public void WhenConfigureIdMoreThanOnceThenUseSameMapper() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); ICollectionIdMapper firstInstance = null; ICollectionIdMapper secondInstance = null; mapper.Id(x => firstInstance = x); mapper.Id(x => secondInstance = x); firstInstance.Should().Be.SameInstanceAs(secondInstance); }
public void WhenActionIsNullThenAddFilterName() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", null); hbm.filter.Length.Should().Be(1); hbm.filter[0].Satisfy(f => f.name == "filter1" && f.condition == null); }
public void WhenSameNameThenOverrideCondition() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", f => f.Condition("condition1")); mapper.Filter("filter2", f => f.Condition("condition2")); mapper.Filter("filter1", f => f.Condition("anothercondition1")); hbm.filter.Length.Should().Be(2); hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter1" && f.condition == "anothercondition1")); hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter2" && f.condition == "condition2")); }
public void CanSetMoreFiltersThroughAction() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", f => f.Condition("condition1")); mapper.Filter("filter2", f => f.Condition("condition2")); hbm.filter.Length.Should().Be(2); hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter1" && f.condition == "condition1")); hbm.filter.Satisfy(filters => filters.Any(f => f.name == "filter2" && f.condition == "condition2")); }
public void WhenSetTwoCachePropertiesInTwoActionsThenSetTheTwoValuesWithoutLostTheFirst() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Cache(ch => ch.Region("pizza")); mapper.Cache(ch => ch.Usage(CacheUsage.NonstrictReadWrite)); var hbmCache = hbm.cache; hbmCache.Should().Not.Be.Null(); hbmCache.region.Should().Be("pizza"); hbmCache.usage.Should().Be(HbmCacheUsage.NonstrictReadWrite); }
public void CanSetCache() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Cache(x => x.Region("pizza")); hbm.cache.Should().Not.Be.Null(); }
public void CanChangeAccessor() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Access(Accessor.Field); hbm.Access.Should().Not.Be.Null(); }
public void WhenCreatedHasId() { var hbm = new HbmIdbag(); new IdBagMapper(typeof(Animal), typeof(Animal), hbm); Assert.That(hbm.collectionid, Is.Not.Null); }
public void SetBatchSize() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.BatchSize(10); Assert.That(hbm.BatchSize, Is.EqualTo(10)); }
public void SetFetchMode() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Fetch(CollectionFetchMode.Subselect); hbm.fetch.Should().Be(HbmCollectionFetchMode.Subselect); hbm.fetchSpecified.Should().Be.True(); mapper.Fetch(CollectionFetchMode.Join); hbm.fetch.Should().Be(HbmCollectionFetchMode.Join); hbm.fetchSpecified.Should().Be.True(); mapper.Fetch(CollectionFetchMode.Select); hbm.fetch.Should().Be(HbmCollectionFetchMode.Select); hbm.fetchSpecified.Should().Be.False(); }
private Mapping.Collection CreateIdentifierBag(HbmIdbag idbagMapping, string prefix, string path, PersistentClass owner, System.Type containingType, IDictionary<string, MetaAttribute> inheritedMetas) { var idbag = new IdentifierBag(owner); BindCollection(idbagMapping, idbag, prefix, path, containingType, inheritedMetas); AddIdentifierCollectionSecondPass(idbagMapping, idbag, inheritedMetas); return idbag; }
private void BindIdentifierCollectionSecondPass(HbmIdbag idbagMapping, IdentifierCollection model, IDictionary<string, PersistentClass> persitentClasses, IDictionary<string, MetaAttribute> inheritedMetas) { BindCollectionSecondPass(idbagMapping, model, persitentClasses, inheritedMetas); var id = new SimpleValue(model.CollectionTable); new ValuePropertyBinder(id, Mappings).BindSimpleValue(idbagMapping.collectionid, IdentifierCollection.DefaultIdentifierColumnName); model.Identifier = id; new IdGeneratorBinder(Mappings).BindGenerator(id, idbagMapping.collectionid.generator); id.Table.SetIdentifierValue(id); }
private void AddIdentifierCollectionSecondPass(HbmIdbag idbagMapping, IdentifierCollection model, IDictionary<string, MetaAttribute> inheritedMetas) { mappings.AddSecondPass(delegate(IDictionary<string, PersistentClass> persistentClasses) { PreCollectionSecondPass(model); BindIdentifierCollectionSecondPass(idbagMapping, model, persistentClasses, inheritedMetas); PostCollectionSecondPass(model); }); }
public void IdBag(MemberInfo property, Action<IIdBagPropertiesMapper> collectionMapping, Action<ICollectionElementRelation> mapping) { var hbm = new HbmIdbag { name = property.Name }; System.Type propertyType = property.GetPropertyOrFieldType(); System.Type collectionElementType = propertyType.DetermineCollectionElementType(); collectionMapping(new IdBagMapper(Container, collectionElementType, new NoMemberPropertyMapper(), hbm)); mapping(new CollectionElementRelation(collectionElementType, MapDoc, rel => hbm.Item = rel)); AddProperty(hbm); }
public void SetLazy() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Lazy(CollectionLazy.Extra); Assert.That(hbm.Lazy, Is.EqualTo(HbmCollectionLazy.Extra)); mapper.Lazy(CollectionLazy.NoLazy); Assert.That(hbm.Lazy, Is.EqualTo(HbmCollectionLazy.False)); mapper.Lazy(CollectionLazy.Lazy); Assert.That(hbm.Lazy, Is.EqualTo(HbmCollectionLazy.True)); }
public void WhenCreatedHasId() { var hbm = new HbmIdbag(); new IdBagMapper(typeof(Animal), typeof(Animal), hbm); hbm.collectionid.Should().Not.Be.Null(); }
public void SetBatchSize() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.BatchSize(10); hbm.BatchSize.Should().Be.EqualTo(10); }
public void CallKeyMapper() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); bool kmCalled = false; mapper.Key(km => kmCalled = true); hbm.Key.Should().Not.Be.Null(); kmCalled.Should().Be.True(); }
public void SetFetchMode() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Fetch(CollectionFetchMode.Subselect); Assert.That(hbm.fetch, Is.EqualTo(HbmCollectionFetchMode.Subselect)); Assert.That(hbm.fetchSpecified, Is.True); mapper.Fetch(CollectionFetchMode.Join); Assert.That(hbm.fetch, Is.EqualTo(HbmCollectionFetchMode.Join)); Assert.That(hbm.fetchSpecified, Is.True); mapper.Fetch(CollectionFetchMode.Select); Assert.That(hbm.fetch, Is.EqualTo(HbmCollectionFetchMode.Select)); Assert.That(hbm.fetchSpecified, Is.False); }
public void SetCollectionTypeByWrongTypeShouldThrow() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); Executing.This(() => mapper.Type(null)).Should().Throw<ArgumentNullException>(); Executing.This(() => mapper.Type(typeof(object))).Should().Throw<ArgumentOutOfRangeException>(); }
public void SetCollectionTypeByType() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Type(typeof(FakeUserCollectionType)); hbm.CollectionType.Should().Contain("FakeUserCollectionType"); }
public void SetLazy() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Lazy(CollectionLazy.Extra); hbm.Lazy.Should().Be.EqualTo(HbmCollectionLazy.Extra); mapper.Lazy(CollectionLazy.NoLazy); hbm.Lazy.Should().Be.EqualTo(HbmCollectionLazy.False); mapper.Lazy(CollectionLazy.Lazy); hbm.Lazy.Should().Be.EqualTo(HbmCollectionLazy.True); }
public void WhenActionIsNullThenAddFilterName() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", null); Assert.That(hbm.filter.Length, Is.EqualTo(1)); var filter = hbm.filter[0]; Assert.That(filter.condition, Is.EqualTo(null)); Assert.That(filter.name, Is.EqualTo("filter1")); }