public void AddingDuplicateSubscriptionFails() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SubscriptionParameters sub = CreateSubscriptionParams("PubCustomers", "CustomersTest"); subMgr.Add(sub); subMgr.Add(sub); }
[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 CanGetSubscriptionByName() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); subMgr.Add(subParams); subParams = CreateSubscriptionParams("PubTest", "AnotherTest"); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions["CustomersTest"]; Assert.AreEqual("CustomersTest", sub.Subscriber); sub = subMgr.Subscriptions["AnotherTest"]; Assert.AreEqual("AnotherTest", sub.Subscriber); }
public void ContainsKeyReturnsFalseWhenSubscriptionNotPresent() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); Assert.IsFalse(subMgr.Subscriptions.ContainsKey("junk")); subMgr.Add(subParams); Assert.IsFalse(subMgr.Subscriptions.ContainsKey("junk")); }
public void ContainsKeyReturnsTrueWhenSubscriptoinExists() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); subMgr.Add(subParams); Assert.IsTrue(subMgr.Subscriptions.ContainsKey("CustomersTest")); }
public void CanAddSubscription() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); subMgr.Add(subParams); Assert.AreEqual(1, subMgr.Subscriptions.Count); Assert.AreEqual("CustomersTest", subMgr.Subscriptions[0].Subscriber); }
[Ignore] // Requires setting up IIS fro subscription public void PublicationNameIsCorrectAfterSync() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); subMgr.Synchronize(subMgr.Subscriptions[0]); subMgr = CreateSubscriptionManager(); Assert.AreEqual("PubCustomers", subMgr.Subscriptions[0].Publication); }
public void CanDropSubscriptionAfterAppRestart() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); subMgr = CreateSubscriptionManager(); subMgr.Drop(subMgr.Subscriptions[0]); Assert.AreEqual(0, subMgr.Subscriptions.Count); }
public void SyncingDroppedSubscriptionThrowsException() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions[0]; subMgr.Drop(sub); subMgr.Synchronize(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); }
[Ignore] // Requires setting up IIS fro subscription public void DifferentFilterReturnsDifferentData() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); subParams.Filter = "DE"; SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions[0]; subMgr.Synchronize(sub); int count = CountCustomers(connectionString); subMgr.Drop(sub); subParams.Filter = "DK"; subMgr.Add(subParams); sub = subMgr.Subscriptions[0]; subMgr.Synchronize(sub); int count2 = CountCustomers(connectionString); Assert.AreNotEqual(count, count2); }
[Ignore] // Requires setting up IIS fro subscription public void LastSyncTimeBecomesNonNullAfterSync() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); Subscription sub = subMgr.Subscriptions[0]; Assert.IsNull(sub.LastSyncTime); subMgr.Synchronize(sub); subMgr = CreateSubscriptionManager(); Assert.IsNotNull(sub.LastSyncTime); }
public void SynchronizeThrowsProperExceptionIfCredentialsNotFound() { SqlSubscriptionManager manager = new SqlSubscriptionManager(subscriptionDatabase, new SubscriptionNullCredentialServiceMock()); SubscriptionParameters parameters = CreateSubscriptionParams("PubCustomers", "NoCredentials"); Assert.AreEqual(0, manager.Subscriptions.Count); manager.Add(parameters); Subscription subs = manager.Subscriptions[0]; //Throws System.NullReferenceException: manager.Synchronize(subs); Assert.AreEqual(1, manager.Subscriptions.Count); }
[Ignore] // Requires setting up IIS fro subscription public void CanDropSubscriptionByName() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); subMgr.Synchronize("CustomersTest"); subMgr = CreateSubscriptionManager(); subMgr.Drop("CustomersTest"); Assert.AreEqual(0, subMgr.Subscriptions.Count); subMgr = CreateSubscriptionManager(); Assert.AreEqual(0, subMgr.Subscriptions.Count); }
public void CanAddSubscriptionWithReplicationInstance() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SqlCeReplication repl = new SqlCeReplication(); repl.Publication = "PubCustomers"; repl.Publisher = "MOBGUISQL01"; repl.PublisherDatabase = "AdventureWorksMobileStaging"; repl.InternetUrl = "http://mobguisql01/PublicationCustomers/sqlcesa30.dll"; repl.Subscriber = "Test"; repl.HostName = "DE"; subMgr.Add(repl); Assert.AreEqual(1, subMgr.Subscriptions.Count); Assert.AreEqual("Test", subMgr.Subscriptions[0].Subscriber); }
[Ignore] // Requires setting up IIS fro subscription public void LastSyncTimeUpdatedAfterSync() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); subMgr.Add(subParams); Assert.IsNull(subMgr.Subscriptions[0].LastSyncTime); subMgr.Synchronize(subMgr.Subscriptions[0]); Assert.IsNotNull(subMgr.Subscriptions[0].LastSyncTime); DateTime oldSyncTime = (DateTime)subMgr.Subscriptions[0].LastSyncTime; Thread.Sleep(1000); subMgr.Synchronize(subMgr.Subscriptions[0]); Assert.IsTrue(subMgr.Subscriptions[0].LastSyncTime > oldSyncTime); }
[Ignore] // Requires setting up IIS fro subscription public void CanSyncBySubscriberName() { SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest"); SqlSubscriptionManager subMgr = CreateSubscriptionManager(); subMgr.Add(subParams); using (Database database = new SqlDatabase(connectionString)) { Assert.IsFalse(database.TableExists("Customer")); subMgr.Synchronize("CustomersTest"); Assert.IsTrue(database.TableExists("Customer"), "Customer table doesn't exist"); Assert.IsTrue(CountCustomers(connectionString) > 0, "Didn't return any records"); } }
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 ExtendedPropsArePutIntoReplicationObject() { SqlSubscriptionManager subMgr = CreateSubscriptionManager(); SqlCeReplication repl = new SqlCeReplication(); repl.Publication = "PubCustomers"; repl.Publisher = "MOBGUISQL01"; repl.PublisherDatabase = "AdventureWorksMobileStaging"; repl.InternetUrl = "http://mobguisql01/PublicationCustomers/sqlcesa30.dll"; repl.Subscriber = "Test"; repl.HostName = "DE"; repl.Distributor = "junk"; SubscriptionCredentialsMock.FoundJunkDistributor = false; subMgr.Add(repl); try { subMgr.Synchronize(subMgr.Subscriptions[0]); } catch {} Assert.IsTrue(SubscriptionCredentialsMock.FoundJunkDistributor); }
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"); }