[Ignore] // Requires review public void AsynchronousSyncFiresEvents() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); subMgr.Add(subParams); bool didStartTableDownload = false; bool didSyncCompletion = false; bool didSynchronization = false; Subscription sub = subMgr.Subscriptions[0]; sub.SyncCompleted += delegate { didSyncCompletion = true; }; sub.SyncProgress += delegate { didSynchronization = true; }; sub.TableDownloadStarted += delegate { didStartTableDownload = true; }; subMgr.BeginSynchronize(sub); sub.AsyncResult.AsyncWaitHandle.WaitOne(asyncTimeout, false); Assert.IsTrue(didStartTableDownload); Assert.IsTrue(didSyncCompletion); Assert.IsTrue(didSynchronization); subMgr.EndSynchronize(sub); }
public void AsyncSyncOfOldSubscriptionFails() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions[0]; subMgr = CreateSubscriptionManager(); subMgr.BeginSynchronize(sub); }
public void BeginSynchronizeThrowsProperExceptionIfCredentialsNotFound() { SqlSubscriptionManager manager = new SqlSubscriptionManager(subscriptionDatabase, new SubscriptionNullCredentialServiceMock()); SubscriptionParameters parameters = CreateSubscriptionParams("PubCustomers", "NoCredentials"); manager.Add(parameters); Subscription sub = manager.Subscriptions[0]; //Throws System.NullReferenceException: manager.BeginSynchronize(sub); sub.AsyncResult.AsyncWaitHandle.WaitOne(10000, false); manager.EndSynchronize(sub); Assert.IsNotNull(sub.LastSyncTime); }
[Ignore] // Requires review public void AsynchronousSyncUpdatesLastSyncTime() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions[0]; subMgr.BeginSynchronize(sub); sub.AsyncResult.AsyncWaitHandle.WaitOne(asyncTimeout, false); Assert.IsTrue(sub.AsyncResult.IsCompleted); Assert.IsNotNull(sub.LastSyncTime); subMgr.EndSynchronize(sub); Assert.IsNotNull(sub.LastSyncTime); }
public void CanCancelAsynchronousSync() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions[0]; subMgr.BeginSynchronize(sub); sub.AsyncResult.AsyncWaitHandle.WaitOne(500, false); subMgr.CancelSynchronize(sub); sub.AsyncResult.AsyncWaitHandle.WaitOne(asyncTimeout, false); using (Database database = new SqlDatabase(connectionString)) { Assert.IsFalse(database.TableExists("Customer")); } }
public void AsyncEndSyncReloadsSubscriptionsEvenWhenThrowingException() { SubscriptionParameters subParams = CreateSubscriptionParams("NoSuchPublication", "Test"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions["Test"]; subMgr.BeginSynchronize(sub); sub.AsyncResult.AsyncWaitHandle.WaitOne(asyncTimeout, false); subMgr.ClearCache(); try { subMgr.EndSynchronize(sub); } catch { } Assert.IsTrue(subMgr.SubscriptionsAreCurrent); }
public void AsynEndSyncThrowsExceptionWhenNoSuchPublication() { SubscriptionParameters subParams = CreateSubscriptionParams("NoSuchPublication", "Test"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions["Test"]; subMgr.BeginSynchronize(sub); sub.AsyncResult.AsyncWaitHandle.WaitOne(asyncTimeout, false); SqlCeException endException = null; try { subMgr.EndSynchronize(sub); } catch (SqlCeException ex) { endException = ex; } Assert.IsNotNull(endException, "Did not raise excepected exception"); }