public void CachingRepoQueryGenericQueryFilterTest() { GetRepos(nameof(CachingRepoQueryStringParameterTest), out MongoRepository mongoRepo, out CachingRepository cachingRepo); string name = 6.RandomLetters(); TestMonkey data = new TestMonkey { Name = name }; mongoRepo.Save(data); object result = cachingRepo.Query <TestMonkey>(QueryFilter.Where("Name") == name).ToArray().First(); Expect.IsNotNull(result); Expect.AreEqual(typeof(TestMonkey), result.GetType()); Expect.CanCast <TestMonkey>(result); }
public void CachingRepoQueryTypeDynamicParameterTest() { GetRepos(nameof(CachingRepoQueryStringParameterTest), out MongoRepository mongoRepo, out CachingRepository cachingRepo); string name = 6.RandomLetters(); TestMonkey data = new TestMonkey { Name = name }; mongoRepo.Save(data); object result = cachingRepo.Query(typeof(TestMonkey), new { Name = name }).First(); Expect.IsNotNull(result); Expect.AreEqual(typeof(TestMonkey), result.GetType()); Expect.CanCast <TestMonkey>(result); }
public void CachingRepoQueryGenericTypeDictionaryParameterTest() { GetRepos(nameof(CachingRepoQueryStringParameterTest), out MongoRepository mongoRepo, out CachingRepository cachingRepo); string name = 6.RandomLetters(); TestMonkey data = new TestMonkey { Name = name }; mongoRepo.Save(data); object result = cachingRepo.Query <TestMonkey>(new Dictionary <string, object>() { { "Name", name } }).First(); Expect.IsNotNull(result); Expect.AreEqual(typeof(TestMonkey), result.GetType()); Expect.CanCast <TestMonkey>(result); }
public void CachingRepoQueryGenericTypeFuncParameterTest() { DaoRepository daoRepo; CachingRepository cachingRepo; GetRepos(nameof(CachingRepoQueryStringParameterTest), out daoRepo, out cachingRepo); string name = 6.RandomLetters(); TestMonkey data = new TestMonkey { Name = name }; daoRepo.Save(data); object result = cachingRepo.Query <TestMonkey>((o) => o.Name.Equals(name)).First(); Expect.IsNotNull(result); Expect.AreEqual(typeof(TestMonkey), result.GetType()); Expect.CanCast <TestMonkey>(result); }
public void CachingRepoQueryTypeFuncParameterTest() { GetRepos(nameof(CachingRepoQueryStringParameterTest), out MongoRepository mongoRepo, out CachingRepository cachingRepo); string name = 6.RandomLetters(); TestMonkey data = new TestMonkey { Name = name }; mongoRepo.Save(data); object result = cachingRepo.Query(typeof(TestMonkey), (o) => o.Property("Name").ToString() == name).First(); Expect.IsNotNull(result); Expect.AreEqual(typeof(TestMonkey), result.GetType()); Expect.CanCast <TestMonkey>(result); object result2 = cachingRepo.Query(typeof(TestMonkey), (o) => o.Property("Name").ToString().Equals(name)).First(); Expect.IsNotNull(result2); Expect.AreEqual(typeof(TestMonkey), result2.GetType()); Expect.CanCast <TestMonkey>(result2); }