예제 #1
0
        public IEnumerator TestInsertCommandCreation() => UniTask.ToCoroutine(async() =>
        {
            using (var dbConnection =
                       new DbConnection(SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create))
            {
                var obj1  = new TestObj();
                var obj2  = new TestObj();
                var taskA = UniTask.Run(() => { dbConnection.Insert(obj1); });
                var taskB = UniTask.Run(() => { dbConnection.Insert(obj2); });

                await UniTask.WhenAll(taskA, taskB);
            }
        });
예제 #2
0
        public IEnumerator TestLoad() => UniTask.ToCoroutine(async() =>
        {
            try
            {
                var tokenSource = new CancellationTokenSource();
                var tasks       = new List <UniTask>();
                tasks.Add(new DbReader(tokenSource.Token).Run());
                tasks.Add(new DbWriter(tokenSource.Token).Run());

                // Wait 5sec
                tokenSource.CancelAfter(5000);

                await UniTask.WhenAll(tasks);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.ToString());
            }
        });