public void WhenCreatedHasId() { var hbm = new HbmIdbag(); new IdBagMapper(typeof(Animal), typeof(Animal), hbm); Assert.That(hbm.collectionid, Is.Not.Null); }
public IdBagMapper(System.Type ownerType, System.Type elementType, IAccessorPropertyMapper accessorMapper, HbmIdbag mapping) { if (ownerType == null) { throw new ArgumentNullException("ownerType"); } if (elementType == null) { throw new ArgumentNullException("elementType"); } if (mapping == null) { throw new ArgumentNullException("mapping"); } OwnerType = ownerType; ElementType = elementType; this.mapping = mapping; if (mapping.Key == null) { mapping.key = new HbmKey(); } keyMapper = new KeyMapper(ownerType, mapping.Key); if (mapping.collectionid == null) { mapping.collectionid = new HbmCollectionId(); } idMapper = new CollectionIdMapper(mapping.collectionid); entityPropertyMapper = accessorMapper; }
public void WhenCreatedHasId() { var hbm = new HbmIdbag(); new IdBagMapper(typeof(Animal), typeof(Animal), hbm); hbm.collectionid.Should().Not.Be.Null(); }
public void SetCollectionTypeByType() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Type(typeof(FakeUserCollectionType)); Assert.That(hbm.CollectionType, Is.StringContaining("FakeUserCollectionType")); }
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 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 SetCollectionTypeByWrongTypeShouldThrow() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); Assert.That(() => mapper.Type(null), Throws.TypeOf <ArgumentNullException>()); Assert.That(() => mapper.Type(typeof(object)), Throws.TypeOf <ArgumentOutOfRangeException>()); }
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 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 SetCollectionTypeByGenericType() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Type <FakeUserCollectionType>(); Assert.That(hbm.CollectionType, Does.Contain("FakeUserCollectionType")); }
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 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")); }
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 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 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 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 CallKeyMapper() { var hbm = new HbmIdbag(); var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); bool kmCalled = false; mapper.Key(km => kmCalled = true); Assert.That(hbm.Key, Is.Not.Null); Assert.That(kmCalled, Is.True); }
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 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 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, new NoMemberPropertyMapper(), hbm)); mapping(new CollectionElementRelation(collectionElementType, MapDoc, rel => hbm.Item = rel)); AddProperty(hbm); }
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 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 CanSetAFilterThroughAction() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", f => f.Condition("condition1")); hbm.filter.Length.Should().Be(1); hbm.filter[0].Satisfy(f => f.name == "filter1" && f.condition == "condition1"); }
public void CanSetCache() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Cache(x => x.Region("pizza")); Assert.That(hbm.cache, Is.Not.Null); }
public void CanChangeAccessor() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Access(Accessor.Field); Assert.That(hbm.Access, Is.Not.Null); }
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 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); Assert.That(firstInstance, Is.SameAs(secondInstance)); }
public void CanSetAFilterThroughAction() { var hbm = new HbmIdbag { name = "Children" }; var mapper = new IdBagMapper(typeof(Animal), typeof(Animal), hbm); mapper.Filter("filter1", f => f.Condition("condition1")); Assert.That(hbm.filter.Length, Is.EqualTo(1)); Assert.That(hbm.filter[0].condition, Is.EqualTo("condition1")); Assert.That(hbm.filter[0].name, Is.EqualTo("filter1")); }
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)); }