コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: UnitTests.cs プロジェクト: dekkerb115/Bam.Net
        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);
        }
コード例 #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);
        }