Exemplo n.º 1
0
        public async Task All_LimitSpecification()
        {
            var depts   = new Department(ProviderName);
            var allRows = await(await depts.AllAsync(limit: 10)).ToListAsync();

            Assert.AreEqual(10, allRows.Count);
        }
Exemplo n.º 2
0
        public async Task Save_MultipleRows()
        {
            var depts = new Department(ProviderName);

            object[] toSave = new object[]
            {
                new { DNAME = "Massive Dep", LOC = "Beach" }.ToExpando(),
                new { DNAME = "Massive Dep", LOC = "DownTown" }.ToExpando()
            };
            var result = await depts.SaveAsync(toSave);

            Assert.AreEqual(2, result);
            foreach (dynamic o in toSave)
            {
                Assert.IsTrue(o.DEPTNO > 0);
            }

            // read them back, update them, save them again,
            var savedDeps = await(await depts.AllAsync(where : "WHERE DEPTNO=:0 OR DEPTNO=:1", args: new object[] { ((dynamic)toSave[0]).DEPTNO, ((dynamic)toSave[1]).DEPTNO })).ToListAsync();

            Assert.AreEqual(2, savedDeps.Count);
            savedDeps[0].LOC += "C";
            savedDeps[1].LOC += "C";
            result            = await depts.SaveAsync(toSave);

            Assert.AreEqual(2, result);
            Assert.AreEqual(1, await depts.DeleteAsync(savedDeps[0].DEPTNO));
            Assert.AreEqual(1, await depts.DeleteAsync(savedDeps[1].DEPTNO));
        }
Exemplo n.º 3
0
        public async Task NormalWhereCall()
        {
            // Check that things are up and running normally before trying the new stuff
            var db   = new Department(ProviderName);
            var rows = await db.AllAsync(where : "LOC = :0", args : "Nowhere");

            Assert.AreEqual(9, (await rows.ToListAsync()).Count);
        }
Exemplo n.º 4
0
        public async Task All_NoParameters()
        {
            var depts   = new Department(ProviderName);
            var allRows = await(await depts.AllAsync()).ToListAsync();

            Assert.AreEqual(60, allRows.Count);
            foreach (var d in allRows)
            {
                Console.WriteLine("{0} {1} {2}", d.DEPTNO, d.DNAME, d.LOC);
            }
        }
Exemplo n.º 5
0
        public async Task All_WhereSpecification_OrderBySpecification_LimitSpecification()
        {
            var depts   = new Department(ProviderName);
            var allRows = await(await depts.AllAsync(limit: 6, orderBy: "DEPTNO DESC", where : "WHERE LOC=:0", args: "Nowhere")).ToListAsync();

            Assert.AreEqual(6, allRows.Count);
            int previous = int.MaxValue;

            foreach (var r in allRows)
            {
                int current = r.DEPTNO;
                Assert.IsTrue(current <= previous);
                previous = current;
            }
        }