Ejemplo n.º 1
0
        public void SchemaRepoTestOneWhere()
        {
            TestDaoRepository testDaoRepo = new TestDaoRepository("TestDaoRepoSchema");

            string theName = "The Test Parent 1 ({0})"._Format(8.RandomLetters());

            ClrTypes.Parent parent = new ClrTypes.Parent {
                Name = theName
            };
            OutLine("Saving parent 1", ConsoleColor.Cyan);
            testDaoRepo.Save(parent);

            ClrTypes.Parent retrieved = testDaoRepo.OneParentWhere(c => c.Name == parent.Name);
            Expect.IsNotNull(retrieved);
            Expect.AreEqual(theName, retrieved.Name);
        }
Ejemplo n.º 2
0
        public void SchemaRepoTestTopWhere()
        {
            TestDaoRepository testDaoRepo = new TestDaoRepository("TestDaoRepoSchema");
            string            startsWith  = 4.RandomLetters();

            ClrTypes.Parent parent  = GetClrParent();
            ClrTypes.Parent parent2 = GetClrParent();
            ClrTypes.Parent parent3 = GetClrParent();
            parent.Name  = $"{startsWith}: {parent.Name}";
            parent2.Name = $"{startsWith}: {parent2.Name}";
            testDaoRepo.Save(parent);
            testDaoRepo.Save(parent2);
            testDaoRepo.Save(parent3);

            IEnumerable <ClrTypes.Parent> retrieved = testDaoRepo.TopParentsWhere(2, c => c.Name.StartsWith(startsWith));

            Expect.IsNotNull(retrieved);
            Expect.AreEqual(retrieved.Count(), 2);
            Expect.AreEqual(2, testDaoRepo.CountParentsWhere(c => c.Name.StartsWith(startsWith)));
        }
Ejemplo n.º 3
0
        public async void SchemaRepoBatchQueryTest()
        {
            TestDaoRepository testDaoRepo = new TestDaoRepository("TestDaoRepoSchema");
            string            startsWith  = 4.RandomLetters();

            ClrTypes.Parent parent  = GetClrParent();
            ClrTypes.Parent parent2 = GetClrParent();
            ClrTypes.Parent parent3 = GetClrParent();
            ClrTypes.Parent parent4 = GetClrParent();
            ClrTypes.Parent parent5 = GetClrParent();
            parent.Name  = $"{startsWith}: {parent.Name}";
            parent2.Name = $"{startsWith}: {parent2.Name}";
            parent3.Name = $"{startsWith}: {parent3.Name}";
            parent4.Name = $"{startsWith}: {parent4.Name}";

            testDaoRepo.Save(parent);
            testDaoRepo.Save(parent2);
            testDaoRepo.Save(parent3);

            int?batchCount = 0;
            await testDaoRepo.BatchQueryParents(2, c => c.Name.StartsWith(startsWith), (batch) =>
            {
                batchCount++;
                batch.Each(p => OutLineFormat(p.PropertiesToString()));
            });

            int?batchAll = 0;
            await testDaoRepo.BatchAllParents(2, (batch) =>
            {
                batchAll++;
            });

            Expect.IsGreaterThan(batchAll.Value, 0);
            Expect.AreEqual(2, batchCount.Value);
            OutLineFormat("Parent count: {0}", ConsoleColor.Blue, testDaoRepo.CountParents());
        }