示例#1
0
        public void SyncAll()
        {
            UTWebRequest.SyncData = "firstSync.zip";
            Mobeelizer.Login("user", "password", (s) =>
            {
                syncAllLoginEvent.Set();
            });
            syncAllLoginEvent.WaitOne();
            String justAddEntityGuid = string.Empty;

            using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction())
            {
                var        departmentTable = db.GetModelSet <Department>();
                Department de = new Department();
                de.InternalNumber = 1;
                de.Name           = "ddd";
                departmentTable.InsertOnSubmit(de);
                db.SubmitChanges();
                justAddEntityGuid = de.Guid;
            }

            MobeelizerOperationError status = null;

            Mobeelizer.SyncAll((s) =>
            {
                status = s;
                this.syncAllEvent.Set();
            });
            syncAllEvent.WaitOne();
            Assert.IsNull(status);
            Department foundObject = null;

            using (IMobeelizerTransaction db = Mobeelizer.GetDatabase().BeginTransaction())
            {
                var departmentTable = db.GetModelSet <Department>();
                var query           = from d in departmentTable where d.Guid == justAddEntityGuid select d;
                try
                {
                    foundObject = query.Single();
                }
                catch { }
                Assert.IsNull(foundObject);
                Assert.AreEqual(1, departmentTable.Count());
            }
        }