Ejemplo n.º 1
0
        public async Task TestInsert()
        {//Test insert
            Sqo.SiaqodbConfigurator.SetLicense(@" qU3TtvA4T4L30VSlCCGUTSgbmx5WI47jJrL1WHN2o/gg5hnL45waY5nSxqWiFmnG");

            SiaqodbMobile mob1 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", "db1");

            mob1.AddSyncType <TodoItem>("TodoItem");

            TodoItem item = new TodoItem();

            item.Text = "Testitem1";
            item.Id   = Guid.NewGuid().ToString();
            mob1.StoreObject(item);
            mob1.Flush();
            await mob1.SyncProvider.Synchronize();

            SiaqodbMobile mob2 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", "db2");

            mob2.AddSyncType <TodoItem>("TodoItem");


            await mob2.SyncProvider.Synchronize();


            TodoItem todoItem = (from TodoItem todo in mob2
                                 where todo.Id == item.Id
                                 select todo).FirstOrDefault();

            Assert.AreEqual(item.Id, todoItem.Id);
            mob2.Close();
            mob1.Close();
        }
Ejemplo n.º 2
0
        public async Task TestConflictDeleteDelete()
        {
            //delete on C1 and delete on C2->conflict-> nothing happens on clients
            Sqo.SiaqodbConfigurator.SetLicense(@" qU3TtvA4T4L30VSlCCGUTSgbmx5WI47jJrL1WHN2o/gg5hnL45waY5nSxqWiFmnG");
            SiaqodbMobile mob1 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", "db1");

            mob1.AddSyncType <TodoItem>("TodoItem");

            TodoItem item = new TodoItem();

            item.Text = "Testitem1";
            item.Id   = Guid.NewGuid().ToString();
            mob1.StoreObject(item);
            mob1.Flush();
            await mob1.SyncProvider.Synchronize();

            TodoItem itemSynced = (from TodoItem todo in mob1
                                   where todo.Id == item.Id
                                   select todo).FirstOrDefault();

            mob1.Delete(itemSynced);
            mob1.Flush();


            SiaqodbMobile mob2 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", "db2");

            mob2.AddSyncType <TodoItem>("TodoItem");
            await mob2.SyncProvider.Synchronize();

            TodoItem itemSyncedDeleted = (from TodoItem todo in mob2
                                          where todo.Id == item.Id
                                          select todo).FirstOrDefault();

            mob2.Delete(itemSyncedDeleted);
            mob2.Flush();

            await mob1.SyncProvider.Synchronize();

            await mob2.SyncProvider.Synchronize();

            TodoItem deleted = (from TodoItem todo in mob1
                                where todo.Id == item.Id
                                select todo).FirstOrDefault();

            Assert.IsNull(deleted);

            TodoItem deleted2 = (from TodoItem todo in mob2
                                 where todo.Id == item.Id
                                 select todo).FirstOrDefault();

            Assert.IsNull(deleted2);


            mob1.Close();
            mob2.Close();
        }
Ejemplo n.º 3
0
        public async Task TestUpdate()
        {
            StorageFolder db1 = await dbFolder.CreateFolderAsync("db1", CreationCollisionOption.OpenIfExists);

            StorageFolder db2 = await dbFolder.CreateFolderAsync("db2", CreationCollisionOption.OpenIfExists);

            Sqo.SiaqodbConfigurator.SetLicense(@" qU3TtvA4T4L30VSlCCGUTSgbmx5WI47jJrL1WHN2o/gg5hnL45waY5nSxqWiFmnG");
            SiaqodbMobile mob1 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", db1);

            mob1.AddSyncType <TodoItem>("TodoItem");

            TodoItem item = new TodoItem();

            item.Text = "Testitem1";
            item.Id   = Guid.NewGuid().ToString();
            await mob1.StoreObjectAsync(item);

            await mob1.FlushAsync();

            await mob1.SyncProvider.Synchronize();

            IList <TodoItem> all = mob1.LoadAll <TodoItem>();

            all[all.Count - 1].Text = "TestUpdate";

            string idUpdated = all[all.Count - 1].Id;
            await mob1.StoreObjectAsync(all[all.Count - 1]);

            await mob1.FlushAsync();

            await mob1.SyncProvider.Synchronize();

            SiaqodbMobile mob2 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", db2);

            mob2.AddSyncType <TodoItem>("TodoItem");
            await mob2.SyncProvider.Synchronize();

            TodoItem todoItem = await(from TodoItem todo in mob2
                                      where todo.Id == idUpdated
                                      select todo).FirstOrDefaultAsync();

            Assert.AreEqual("TestUpdate", todoItem.Text);

            TodoItem todoItemMob1 = await(from TodoItem todo in mob1
                                          where todo.Id == idUpdated
                                          select todo).FirstOrDefaultAsync();

            Assert.AreEqual("TestUpdate", todoItemMob1.Text);

            await mob1.CloseAsync();

            await mob2.CloseAsync();
        }
Ejemplo n.º 4
0
        public async Task TestDelete()
        {//Test delete
            StorageFolder db1 = await dbFolder.CreateFolderAsync("db1", CreationCollisionOption.OpenIfExists);

            StorageFolder db2 = await dbFolder.CreateFolderAsync("db2", CreationCollisionOption.OpenIfExists);

            Sqo.SiaqodbConfigurator.SetLicense(@" qU3TtvA4T4L30VSlCCGUTSgbmx5WI47jJrL1WHN2o/gg5hnL45waY5nSxqWiFmnG");
            SiaqodbMobile mob1 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", db1);

            mob1.AddSyncType <TodoItem>("TodoItem");

            TodoItem item = new TodoItem();

            item.Text = "Testitem1";
            item.Id   = Guid.NewGuid().ToString();
            await mob1.StoreObjectAsync(item);

            await mob1.FlushAsync();

            await mob1.SyncProvider.Synchronize();

            await mob1.DeleteAsync(item);

            await mob1.FlushAsync();

            await mob1.SyncProvider.Synchronize();

            TodoItem deleted = await(from TodoItem todo in mob1
                                     where todo.Id == item.Id
                                     select todo).FirstOrDefaultAsync();

            Assert.IsNull(deleted);


            SiaqodbMobile mob2 = new SiaqodbMobile(@"https://cristidot.azure-mobile.net/",
                                                   "RLINABsktmvkzJMegbicNASWkzRzEW97", db2);

            mob2.AddSyncType <TodoItem>("TodoItem");
            await mob2.SyncProvider.Synchronize();

            TodoItem deleted2 = await(from TodoItem todo in mob2
                                      where todo.Id == item.Id
                                      select todo).FirstOrDefaultAsync();

            Assert.IsNull(deleted2);
        }