Esempio n. 1
0
        public void SetMapKey()
        {
            var hbm = new HbmMap();

            new MapMapper <Animal, string, Animal>(hbm);
            hbm.Item.Should().Not.Be.Null().And.Be.OfType <HbmMapKey>();
        }
Esempio n. 2
0
        public void SetSort()
        {
            var hbm    = new HbmMap();
            var mapper = new MapMapper <Animal, string, Animal>(hbm);

            mapper.Sort();
            hbm.Sort.Should().Be.EqualTo("natural");
        }
Esempio n. 3
0
        public void SetMapKey()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();

            new MapMapper(typeof(Animal), typeof(string), typeof(Animal), hbm, mapdoc);
            hbm.Item.Should().Not.Be.Null().And.Be.OfType <HbmMapKey>();
        }
Esempio n. 4
0
        public void SetBatchSize()
        {
            var hbm    = new HbmMap();
            var mapper = new MapMapper <Animal, string, Animal>(hbm);

            mapper.BatchSize = 10;
            hbm.BatchSize.Should().Be.EqualTo(10);
        }
Esempio n. 5
0
        public void SetWhere()
        {
            var hbm    = new HbmMap();
            var mapper = new MapMapper <Animal, string, Animal>(hbm);

            mapper.Where = "c > 10";
            hbm.Where.Should().Be.EqualTo("c > 10");
        }
Esempio n. 6
0
        public void SetSort()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(string), typeof(Animal), hbm, mapdoc);

            mapper.Sort();
            hbm.Sort.Should().Be.EqualTo("natural");
        }
Esempio n. 7
0
        public void SetBatchSize()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(string), typeof(Animal), hbm, mapdoc);

            mapper.BatchSize(10);
            hbm.BatchSize.Should().Be.EqualTo(10);
        }
Esempio n. 8
0
        public void SetWhere()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(string), typeof(Animal), hbm, mapdoc);

            mapper.Where("c > 10");
            hbm.Where.Should().Be.EqualTo("c > 10");
        }
Esempio n. 9
0
 private void AddMapSecondPass(HbmMap mapMapping, Map model, IDictionary <string, MetaAttribute> inheritedMetas)
 {
     mappings.AddSecondPass(delegate(IDictionary <string, PersistentClass> persistentClasses)
     {
         PreCollectionSecondPass(model);
         BindMapSecondPass(mapMapping, model, persistentClasses, inheritedMetas);
         PostCollectionSecondPass(model);
     });
 }
Esempio n. 10
0
        public void SetCollectionTypeByType()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(Animal), typeof(string), hbm, mapdoc);

            mapper.Type(typeof(FakeUserCollectionType));
            hbm.CollectionType.Should().Contain("FakeUserCollectionType");
        }
Esempio n. 11
0
        private Mapping.Collection CreateMap(HbmMap mapMapping, string prefix, string path,
                                             PersistentClass owner, System.Type containingType, IDictionary <string, MetaAttribute> inheritedMetas)
        {
            var map = new Map(owner);

            BindCollection(mapMapping, map, prefix, path, containingType, inheritedMetas);
            AddMapSecondPass(mapMapping, map, inheritedMetas);
            return(map);
        }
Esempio n. 12
0
        public void CallKeyMapper()
        {
            var  hbm      = new HbmMap();
            var  mapper   = new MapMapper <Animal, string, Animal>(hbm);
            bool kmCalled = false;

            mapper.Key(km => kmCalled = true);
            hbm.Key.Should().Not.Be.Null();
            kmCalled.Should().Be.True();
        }
Esempio n. 13
0
        public void SetMutable()
        {
            var hbm    = new HbmMap();
            var mapper = new MapMapper <Animal, string, Animal>(hbm);

            mapper.Mutable = true;
            hbm.Mutable.Should().Be.True();
            mapper.Mutable = false;
            hbm.Mutable.Should().Be.False();
        }
Esempio n. 14
0
        public void CanSetCache()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(Animal), typeof(string), hbm, mapdoc);

            mapper.Cache(x => x.Region("pizza"));

            hbm.cache.Should().Not.Be.Null();
        }
Esempio n. 15
0
        public void WhenActionIsNullThenAddFilterName()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(Animal), typeof(string), hbm, mapdoc);

            mapper.Filter("filter1", null);
            hbm.filter.Length.Should().Be(1);
            hbm.filter[0].Satisfy(f => f.name == "filter1" && f.condition == null);
        }
Esempio n. 16
0
        public void CanSetAFilterThroughAction()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(Animal), typeof(string), hbm, mapdoc);

            mapper.Filter("filter1", f => f.Condition("condition1"));
            hbm.filter.Length.Should().Be(1);
            hbm.filter[0].Satisfy(f => f.name == "filter1" && f.condition == "condition1");
        }
Esempio n. 17
0
        public void SetMutable()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(string), typeof(Animal), hbm, mapdoc);

            mapper.Mutable(true);
            hbm.Mutable.Should().Be.True();
            mapper.Mutable(false);
            hbm.Mutable.Should().Be.False();
        }
Esempio n. 18
0
        public void CallKeyMapper()
        {
            var  mapdoc   = new HbmMapping();
            var  hbm      = new HbmMap();
            var  mapper   = new MapMapper(typeof(Animal), typeof(string), typeof(Animal), hbm, mapdoc);
            bool kmCalled = false;

            mapper.Key(km => kmCalled = true);
            hbm.Key.Should().Not.Be.Null();
            kmCalled.Should().Be.True();
        }
Esempio n. 19
0
        public void WhenMapKeyTypeIsNotPrimitiveTypeThenKeyIsMapKeyManyToManyWithClassAssigned()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();

            new MapMapper(typeof(Animal), typeof(Animal), typeof(string), hbm, mapdoc);
            hbm.Item.Should().Not.Be.Null().And.Be.OfType <HbmMapKeyManyToMany>();
            var mapKey = (HbmMapKeyManyToMany)hbm.Item;

            mapKey.Class.Should().Contain(typeof(Animal).Name);
        }
Esempio n. 20
0
        public void WhenAssignElementRelationThenUseHbmMapKeyElement()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Element(mkm => { });

            hbmMap.Item.Should().Be.OfType <HbmMapKey>();
        }
Esempio n. 21
0
        public void SetLazy()
        {
            var hbm    = new HbmMap();
            var mapper = new MapMapper <Animal, string, 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);
        }
Esempio n. 22
0
        public void CanChangeAccessor()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap {
                name = "Children"
            };
            var mapper = new MapMapper(typeof(Animal), typeof(Animal), typeof(string), hbm, mapdoc);

            mapper.Access(Accessor.Field);

            hbm.Access.Should().Not.Be.Null();
        }
Esempio n. 23
0
        public void WhenAssignElementRelationThenCallActionWithNotNullParameter()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);
            var called     = false;

            mapper.Element(mkm => { called = true;
                                    mkm.Should().Not.Be.Null(); });

            called.Should().Be.True();
        }
Esempio n. 24
0
        public void Map <TKey, TElement>(Expression <Func <TEntity, IDictionary <TKey, TElement> > > property,
                                         Action <ICollectionPropertiesMapper <TEntity, TElement> > collectionMapping,
                                         Action <ICollectionElementRelation <TElement> > mapping) where TElement : class
        {
            var memberInfo = TypeUtils.DecodeMemberAccessExpression(property);
            var hbm        = new HbmMap {
                name = memberInfo.Name
            };

            collectionMapping(new MapMapper <TEntity, TKey, TElement>(hbm));
            mapping(new CollectionElementRelation <TElement>(MapDoc, rel => hbm.Item1 = rel));
            AddProperty(hbm);
        }
Esempio n. 25
0
        public void SetLazy()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(string), typeof(Animal), hbm, mapdoc);

            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);
        }
Esempio n. 26
0
        public void WhenSameNameThenOverrideCondition()
        {
            var mapdoc = new HbmMapping();
            var hbm    = new HbmMap();
            var mapper = new MapMapper(typeof(Animal), typeof(Animal), typeof(string), hbm, mapdoc);

            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"));
        }
Esempio n. 27
0
        public void WhenAssignElementRelationThenAssignType()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Element(mkm => { });

            var keyElement = (HbmMapKey)hbmMap.Item;

            keyElement.Type.name.Should().Not.Be.Null();
            keyElement.Type.name.Should().Contain("String");
        }
Esempio n. 28
0
        public void WhenAssignComponentRelationThenAssignClass()
        {
            var keyType    = typeof(MyClass);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Component(mkm => { });

            var keyElement = (HbmCompositeMapKey)hbmMap.Item;

            keyElement.Class.Should().Not.Be.Null();
            keyElement.Class.Should().Contain("MyClass");
        }
Esempio n. 29
0
        public void Map <TKey, TElement>(Expression <Func <TEntity, IDictionary <TKey, TElement> > > property,
                                         Action <ICollectionPropertiesMapper <TEntity, TElement> > collectionMapping)
        {
            var memberInfo = TypeUtils.DecodeMemberAccessExpression(property);
            var hbm        = new HbmMap {
                name = memberInfo.Name
            };

            collectionMapping(new MapMapper <TEntity, TKey, TElement>(hbm));
            hbm.Item1 = new HbmElement {
                type1 = TypeUtils.GetTypeName <TElement>()
            };
            AddProperty(hbm);
        }
Esempio n. 30
0
        public void WhenAssignElementRelationThenActionShouldReuseSameInstanceOfHbmElement()
        {
            var keyType    = typeof(string);
            var hbmMap     = new HbmMap();
            var hbmMapping = new HbmMapping();
            var mapper     = new MapKeyRelation(keyType, hbmMap, hbmMapping);

            mapper.Element(mkm => mkm.Column("pizza"));
            mapper.Element(mkm => mkm.Length(30));

            var keyElement = (HbmMapKey)hbmMap.Item;

            keyElement.length.Should().Be("30");
            keyElement.column.Should().Be("pizza");
        }