Ejemplo n.º 1
0
        public async Task ClearDatabaseTest()
        {
            Func <Task <int> > getDbDepCount = async() => (await SqlDependencyEx.GetDependencyDbIdentities(TEST_CONNECTION_STRING, TEST_DATABASE_NAME)).Length;

            var dep1 = new SqlDependencyEx(
                TEST_CONNECTION_STRING,
                TEST_DATABASE_NAME,
                TEST_TABLE_NAME,
                "temp",
                identity: 4);
            var dep2 = new SqlDependencyEx(
                TEST_CONNECTION_STRING,
                TEST_DATABASE_NAME,
                TEST_TABLE_NAME,
                "temp",
                identity: 5);

            dep1.Start();
            // Make sure db has been got 1 dependency object.
            Assert.AreEqual(1, getDbDepCount());
            dep2.Start();
            // Make sure db has been got 2 dependency object.
            Assert.AreEqual(2, getDbDepCount());

            // Forced db cleaning
            await SqlDependencyEx.CleanDatabase(TEST_CONNECTION_STRING, TEST_DATABASE_NAME);

            // Make sure db has no any dependency objects.
            Assert.AreEqual(0, getDbDepCount());

            dep1.Dispose();
            dep2.Dispose();
        }
Ejemplo n.º 2
0
        public void ClearDatabaseTest()
        {
            Func <int> getDbDepCount =
                () =>
                SqlDependencyEx.GetDependencyDbIdentities(
                    TEST_CONNECTION_STRING,
                    TEST_DATABASE_NAME).Length;

            var options = new SqlDependencyExOptions
            {
                ConnectionString = TEST_CONNECTION_STRING,
                DatabaseName     = TEST_DATABASE_NAME,
                TableName        = TEST_TABLE_NAME,
                SchemaName       = "temp"
            };

            var dep1 = new SqlDependencyEx(
                options,
                identity: 4);
            var dep2 = new SqlDependencyEx(
                options,
                identity: 5);

            dep1.Start();
            // Make sure db has been got 1 dependency object.
            Assert.AreEqual(1, getDbDepCount());
            dep2.Start();
            // Make sure db has been got 2 dependency object.
            Assert.AreEqual(2, getDbDepCount());

            // Forced db cleaning
            SqlDependencyEx.CleanDatabase(TEST_CONNECTION_STRING, TEST_DATABASE_NAME);

            // Make sure db has no any dependency objects.
            Assert.AreEqual(0, getDbDepCount());

            dep1.Dispose();
            dep2.Dispose();
        }