public void SetBatchSize() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.BatchSize(10); hbm.BatchSize.Should().Be.EqualTo(10); }
public void SetCollectionTypeByGenericType() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.Type<FakeUserCollectionType>(); hbm.CollectionType.Should().Contain("FakeUserCollectionType"); }
public void SetWhere() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.Where("c > 10"); hbm.Where.Should().Be.EqualTo("c > 10"); }
public void SetSort() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.Sort(); hbm.Sort.Should().Be.EqualTo("natural"); }
public void SetWhere() { var hbm = new HbmSet(); var mapper = new SetMapper <Animal, Animal>(hbm); mapper.Where = "c > 10"; hbm.Where.Should().Be.EqualTo("c > 10"); }
public void SetBatchSize() { var hbm = new HbmSet(); var mapper = new SetMapper <Animal, Animal>(hbm); mapper.BatchSize = 10; hbm.BatchSize.Should().Be.EqualTo(10); }
public void SetSort() { var hbm = new HbmSet(); var mapper = new SetMapper <Animal, Animal>(hbm); mapper.Sort(); hbm.Sort.Should().Be.EqualTo("natural"); }
public void SetCollectionTypeByWrongTypeShouldThrow() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); Executing.This(() => mapper.Type(null)).Should().Throw <ArgumentNullException>(); Executing.This(() => mapper.Type(typeof(object))).Should().Throw <ArgumentOutOfRangeException>(); }
public void SetCollectionTypeByWrongTypeShouldThrow() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); ActionAssert.Throws <ArgumentNullException>(() => mapper.Type(null)); ActionAssert.Throws <ArgumentOutOfRangeException>(() => mapper.Type(typeof(object))); }
public void CanSetAFilterThroughAction() { var hbm = new HbmSet(); var mapper = new SetMapper(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 HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.Cache(x => x.Region("pizza")); hbm.cache.Should().Not.Be.Null(); }
public void CanChangeAccessor() { var hbm = new HbmSet { name = "Children" }; var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.Access(Accessor.Field); hbm.Access.Should().Not.Be.Null(); }
public void SetCollectionTypeByType() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.Type(typeof(FakeUserCollectionType)); hbm.CollectionType.Should().Contain("FakeUserCollectionType"); }
public void WhenActionIsNullThenAddFilterName() { var hbm = new HbmSet(); var mapper = new SetMapper(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 MapValueAdds() { var instance = SetMapper <MyOptions, int> .Create(opt => opt.Set); var options = new MyOptions(); instance.MapValue(options, 10); options.Set.Single().ShouldBe(10); }
public void CallKeyMapper() { var hbm = new HbmSet(); var mapper = new SetMapper(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 CallKeyMapper() { var hbm = new HbmSet(); var mapper = new SetMapper <Animal, 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 HbmSet(); var mapper = new SetMapper <Animal, Animal>(hbm); mapper.Mutable = true; hbm.Mutable.Should().Be.True(); mapper.Mutable = false; hbm.Mutable.Should().Be.False(); }
public void SetMutable() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); mapper.Mutable(true); hbm.Mutable.Should().Be.True(); mapper.Mutable(false); hbm.Mutable.Should().Be.False(); }
public void WhenSameNameThenOverrideCondition() { var hbm = new HbmSet(); var mapper = new SetMapper(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 SetLazy() { var hbm = new HbmSet(); var mapper = new SetMapper(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 SetLazy() { var hbm = new HbmSet(); var mapper = new SetMapper <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); }
public void WhenSetTwoCachePropertiesInTwoActionsThenSetTheTwoValuesWithoutLostTheFirst() { var hbm = new HbmSet(); var mapper = new SetMapper(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 SetFetchMode() { var hbm = new HbmSet(); var mapper = new SetMapper(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(); }
public void SyncSets() { var excludedTypes = new List <string> { "funny", "token" }; var apiSets = _scryfall.GetSets().Where(s => !excludedTypes.Contains(s.SetType)).ToList(); System.Console.WriteLine($"found {apiSets.Count} sets from API"); var dbSets = _db.Sets().ToList(); System.Console.WriteLine($"found {dbSets.Count} sets from DB"); var setsToAdd = apiSets.Where(a => !dbSets.Any(d => d.Id == a.Id)); foreach (var newSet in setsToAdd) { System.Console.WriteLine($"Attempting to add set '{newSet.Name}'"); _db.AddSet(SetMapper.SharedToDb(newSet)); } }
public void SyncCards() { var sets = _db.Sets().OrderBy(s => s.ReleasedAt); foreach (var dbSet in sets) { if (dbSet.Completed == false) { System.Console.WriteLine($"attempting to sync cards for the set {dbSet.Name}"); var cards = _scryfall.GetBySet(dbSet.Code).ToList(); System.Console.WriteLine($"syncing {dbSet.CardCount} cards for the set {dbSet.Name}"); foreach (var card in cards) { _db.AddCard(CardMapper.SharedToDb(card), SetMapper.SharedToDb(dbSet)); } _db.CompleteSet(dbSet); } else { System.Console.WriteLine($"Skipping the set {dbSet.Name}"); } } }
/// <summary> /// Maps one or more argument values to the queue specified by the expression. /// </summary> /// <param name="expression">Expression that identifies the collection.</param> /// <returns>Configuration.</returns> public MultiValueArgumentConfiguration <TOptions, TValue> ToSet( Expression <Func <TOptions, ISet <TValue> > > expression) { Using(SetMapper <TOptions, TValue> .Create(expression)); return(Configuration); }
public void CreateReturnsMultivaluedMapper() { SetMapper <MyOptions, int> .Create(opt => opt.Set).MultiValued.ShouldBeTrue(); }
public void SetCollectionTypeByWrongTypeShouldThrow() { var hbm = new HbmSet(); var mapper = new SetMapper(typeof(Animal), typeof(Animal), hbm); ActionAssert.Throws<ArgumentNullException>(() => mapper.Type(null)); ActionAssert.Throws<ArgumentOutOfRangeException>(() => mapper.Type(typeof(object))); }
public void CreateReturnsInstance() { SetMapper <MyOptions, int> .Create(opt => opt.Set).ShouldNotBeNull(); }