[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 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 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 SyncOfOldSubscriptionFails()
        {
            SubscriptionParameters subParams = CreateSubscriptionParams("PubCustomers", "CustomersTest");
            SqlSubscriptionManager subMgr    = CreateSubscriptionManager();

            subMgr.Add(subParams);

            Subscription sub = subMgr.Subscriptions[0];

            subMgr = CreateSubscriptionManager();
            subMgr.Synchronize(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);
        }
        [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 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);
        }