Esempio n. 1
0
        public static async Task Populate_ASYNC_OpenCursor(ICrudDataStore store)
        {
            const int CNT = 1000;

            for (var i = 0; i < CNT; i++)
            {
                var patient = new TupleData
                {
                    COUNTER = i,
                    DATA    = i.ToString() + "-DATA"
                };
                store.Insert(patient);
            }

            var query  = new Query <TupleData>("CRUD.Queries.Tuple.LoadAll");
            var result = store.LoadOneRowset(query);

            Aver.AreEqual(CNT, result.Count);

            Aver.AreObjectsEqual(0, result[0]["COUNTER"].AsInt());
            Aver.AreObjectsEqual(CNT - 1, result[result.Count - 1]["COUNTER"].AsInt());

            var cursor = await store.OpenCursorAsync(query);

            Aver.IsFalse(cursor.Disposed);
            var cnt = 0;

            foreach (var row in cursor.AsEnumerableOf <TupleData>())
            {
                cnt++;
            }

            Aver.AreEqual(CNT, cnt);
            Aver.IsTrue(cursor.Disposed);  //foreach must have closed the cursor
        }