Example #1
0
        public void UnicodePathsAsync()
        {
            var path = Path.GetTempFileName() + UnicodeText;

            var db = new SQLiteConnectionAsync(path, true);

            db.CreateTableAsync <OrderLine> ().Wait();

            Assert.IsTrue(new FileInfo(path).Length > 0, path);
        }
Example #2
0
        public async void LazyLoadCollection()
        {
            IEnumerable <LazyObject> paramObjs = Faker.RandomCollection(LazyObject.Random);

            // Setup DB & LazyLoader
            SQLiteConnectionAsync   db         = new SQLiteConnectionAsync(new LazyObjectDb());
            DbLazyLoad <LazyObject> lazyLoader =
                await DbLazyLoad <LazyObject> .GetOrCreateInstanceAsync(db).ConfigureAwait(true);

            await db.InsertAllAsync(paramObjs).ConfigureAwait(true);

            // Test shallow loading
            // ToList() is necessary, as db.Table<T> return a custom Enumerable
            // implementation which apparently doesn't allow for true references
            IEnumerable <LazyObject> fetchedObjs =
                await db.Table <LazyObject>().ShallowLoad(lazyLoader).ToListAsync().ConfigureAwait(true);

            fetchedObjs.Should().OnlyContain(lo => lo.Value == null && lo.Id > 0);
            fetchedObjs.ShouldAllBeEquivalentTo(
                paramObjs,
                config =>
                config.Including(ctx => ctx.SelectedMemberPath.EndsWith(".Id"))
                .Including(ctx => ctx.SelectedMemberPath.EndsWith(".Idx")));

            // Test further loading
            IEnumerable <LazyObject> furtherObjs =
                await db.Table <LazyObject>().FurtherLoad(lazyLoader).ToListAsync().ConfigureAwait(true);

            furtherObjs.Should().OnlyContain(lo => lo.Value != null);

            lazyLoader.UpdateFromFurtherLoad(fetchedObjs, furtherObjs, lo => lo.Id);

            fetchedObjs.ShouldAllBeEquivalentTo(
                furtherObjs,
                config => config.Including(ctx => ctx.SelectedMemberPath.EndsWith(".Value")));
            fetchedObjs.ShouldAllBeEquivalentTo(
                paramObjs,
                config =>
                config.Including(ctx => ctx.SelectedMemberPath.EndsWith(".Id"))
                .Including(ctx => ctx.SelectedMemberPath.EndsWith(".Idx")));

            // Test further unloading
            foreach (LazyObject fetchedObj in fetchedObjs)
            {
                lazyLoader.LazyUnload(fetchedObj);
            }

            fetchedObjs.Should().OnlyContain(lo => lo.Value == null && lo.Id > 0);
        }
        void TestAsyncDateTimeOffset(SQLiteConnectionAsync db)
        {
            db.CreateTableAsync <TestObj> ().Wait();

            TestObj o, o2;

            //
            // Ticks
            //
            o = new TestObj {
                ModifiedTime = new DateTimeOffset(2012, 1, 14, 3, 2, 1, TimeSpan.Zero),
            };
            db.InsertAsync(o).Wait();
            o2 = db.GetAsync <TestObj> (o.Id).Result;
            Assert.AreEqual(o.ModifiedTime, o2.ModifiedTime);
        }
        public void AsyncAsTicks()
        {
            var db = new SQLiteConnectionAsync(TestPath.GetTempFileName());

            TestAsyncDateTimeOffset(db);
        }
Example #5
0
        public void AsyncAsString()
        {
            var db = new SQLiteConnectionAsync(TestPath.GetTempFileName(), false);

            TestAsyncDateTime(db);
        }