Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }