コード例 #1
0
 public void SetBatchSize()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
     mapper.BatchSize(10);
     hbm.BatchSize.Should().Be.EqualTo(10);
 }
コード例 #2
0
 public void SetCollectionTypeByGenericType()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
     mapper.Type<FakeUserCollectionType>();
     hbm.CollectionType.Should().Contain("FakeUserCollectionType");
 }
コード例 #3
0
        public void SetBatchSize()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

            mapper.BatchSize(10);
            hbm.BatchSize.Should().Be.EqualTo(10);
        }
コード例 #4
0
        public void SetWhere()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper <Animal, Animal>(hbm);

            mapper.Where = "c > 10";
            hbm.Where.Should().Be.EqualTo("c > 10");
        }
コード例 #5
0
        public void SetCollectionTypeByWrongTypeShouldThrow()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

            ActionAssert.Throws <ArgumentNullException>(() => mapper.Type(null));
            ActionAssert.Throws <ArgumentOutOfRangeException>(() => mapper.Type(typeof(object)));
        }
コード例 #6
0
        public void CanChangeAccessor()
        {
            var hbm = new HbmBag {name = "Children"};
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
            mapper.Access(Accessor.Field);

            hbm.Access.Should().Not.Be.Null();
        }
コード例 #7
0
 public void CanSetAFilterThroughAction()
 {
     var hbm = new HbmBag { name = "Children" };
     var mapper = new BagMapper(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");
 }
コード例 #8
0
        public void CanSetCache()
        {
            var hbm = new HbmBag { name = "Children" };
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
            mapper.Cache(x=> x.Region("pizza"));

            hbm.cache.Should().Not.Be.Null();
        }
コード例 #9
0
        public void SetCollectionTypeByType()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

            mapper.Type(typeof(FakeUserCollectionType));
            hbm.CollectionType.Should().Contain("FakeUserCollectionType");
        }
コード例 #10
0
        public void SetCollectionTypeByWrongTypeShouldThrow()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

            Executing.This(() => mapper.Type(null)).Should().Throw <ArgumentNullException>();
            Executing.This(() => mapper.Type(typeof(object))).Should().Throw <ArgumentOutOfRangeException>();
        }
コード例 #11
0
        public void SetBatchSize()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper <Animal, Animal>(hbm);

            mapper.BatchSize = 10;
            hbm.BatchSize.Should().Be.EqualTo(10);
        }
コード例 #12
0
        public void SetWhere()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

            mapper.Where("c > 10");
            hbm.Where.Should().Be.EqualTo("c > 10");
        }
コード例 #13
0
 public void CallKeyMapper()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
     bool kmCalled = false;
     mapper.Key(km => kmCalled = true);
     hbm.Key.Should().Not.Be.Null();
     kmCalled.Should().Be.True();
 }
コード例 #14
0
        public void SetMutable()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

            mapper.Mutable(true);
            hbm.Mutable.Should().Be.True();
            mapper.Mutable(false);
            hbm.Mutable.Should().Be.False();
        }
コード例 #15
0
        public void SetMutable()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper <Animal, Animal>(hbm);

            mapper.Mutable = true;
            hbm.Mutable.Should().Be.True();
            mapper.Mutable = false;
            hbm.Mutable.Should().Be.False();
        }
コード例 #16
0
        public void CallKeyMapper()
        {
            var  hbm      = new HbmBag();
            var  mapper   = new BagMapper(typeof(Animal), typeof(Animal), hbm);
            bool kmCalled = false;

            mapper.Key(km => kmCalled = true);
            hbm.Key.Should().Not.Be.Null();
            kmCalled.Should().Be.True();
        }
コード例 #17
0
        public void CanSetAFilterThroughAction()
        {
            var hbm = new HbmBag {
                name = "Children"
            };
            var mapper = new BagMapper(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");
        }
コード例 #18
0
        public void CanSetCache()
        {
            var hbm = new HbmBag {
                name = "Children"
            };
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

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

            hbm.cache.Should().Not.Be.Null();
        }
コード例 #19
0
        public void CanChangeAccessor()
        {
            var hbm = new HbmBag {
                name = "Children"
            };
            var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);

            mapper.Access(Accessor.Field);

            hbm.Access.Should().Not.Be.Null();
        }
コード例 #20
0
        public void WhenActionIsNullThenAddFilterName()
        {
            var hbm = new HbmBag {
                name = "Children"
            };
            var mapper = new BagMapper(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);
        }
コード例 #21
0
        public void SetLazy()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper <Animal, 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);
        }
コード例 #22
0
        public void SetLazy()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(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);
        }
コード例 #23
0
        public void WhenSameNameThenOverrideCondition()
        {
            var hbm = new HbmBag {
                name = "Children"
            };
            var mapper = new BagMapper(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"));
        }
コード例 #24
0
        public void SetFetchMode()
        {
            var hbm    = new HbmBag();
            var mapper = new BagMapper(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();
        }
コード例 #25
0
        public void WhenSetTwoCachePropertiesInTwoActionsThenSetTheTwoValuesWithoutLostTheFirst()
        {
            var hbm = new HbmBag {
                name = "Children"
            };
            var mapper = new BagMapper(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);
        }
コード例 #26
0
 public void WhenActionIsNullThenAddFilterName()
 {
     var hbm = new HbmBag { name = "Children" };
     var mapper = new BagMapper(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);
 }
コード例 #27
0
 public void SetCollectionTypeByWrongTypeShouldThrow()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
     ActionAssert.Throws<ArgumentNullException>(() => mapper.Type(null));
     ActionAssert.Throws<ArgumentOutOfRangeException>(() => mapper.Type(typeof(object)));
 }
コード例 #28
0
 public void SetFetchMode()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(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();
 }
コード例 #29
0
 public void SetLazy()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(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);
 }
コード例 #30
0
 public void SetMutable()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
     mapper.Mutable(true);
     hbm.Mutable.Should().Be.True();
     mapper.Mutable(false);
     hbm.Mutable.Should().Be.False();
 }
コード例 #31
0
        public void WhenSetTwoCachePropertiesInTwoActionsThenSetTheTwoValuesWithoutLostTheFirst()
        {
            var hbm = new HbmBag { name = "Children" };
            var mapper = new BagMapper(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);
        }
コード例 #32
0
 public void WhenSameNameThenOverrideCondition()
 {
     var hbm = new HbmBag { name = "Children" };
     var mapper = new BagMapper(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"));
 }
コード例 #33
0
 public void SetWhere()
 {
     var hbm = new HbmBag();
     var mapper = new BagMapper(typeof(Animal), typeof(Animal), hbm);
     mapper.Where("c > 10");
     hbm.Where.Should().Be.EqualTo("c > 10");
 }