Esempio n. 1
0
        public void Test()
        {
            var mapper = new ModelToTableMapper <DatabaseObjectAutoCleanUpAfter2InsertsTestSqlServerModel>();

            mapper.AddMapping(c => c.Name, "First Name").AddMapping(c => c.Surname, "Second Name");

            var tableDependency = new SqlTableDependencyTest <DatabaseObjectAutoCleanUpAfter2InsertsTestSqlServerModel>(
                ConnectionStringForTestUser,
                includeOldValues: true,
                tableName: TableName,
                mapper: mapper,
                stopWithoutDisposing: true);

            tableDependency.OnChanged += TableDependency_OnChanged;
            tableDependency.Start();
            var dbObjectsNaming = tableDependency.DataBaseObjectsNamingConvention;

            Thread.Sleep(500);

            tableDependency.Stop();

            Thread.Sleep(500);

            var t = new Task(ModifyTableContent);

            t.Start();

            Thread.Sleep(1000 * 60 * 4);

            Assert.IsTrue(base.AreAllDbObjectDisposed(dbObjectsNaming));
            Assert.IsTrue(base.CountConversationEndpoints(dbObjectsNaming) == 0);
        }
Esempio n. 2
0
        public void Test()
        {
            var tableDependency = new SqlTableDependencyTest <DatabaseObjectCleanUpSqlServerModel>(
                ConnectionStringForTestUser,
                tableName: TableName,
                stopWithoutDisposing: true);

            tableDependency.OnChanged += TableDependency_OnChanged;
            tableDependency.Start();
            var dbObjectsNaming = tableDependency.DataBaseObjectsNamingConvention;

            Thread.Sleep(10000);

            tableDependency.Stop();

            Thread.Sleep(4 * 60 * 1000);
            Assert.IsTrue(base.AreAllDbObjectDisposed(dbObjectsNaming));
            Assert.IsTrue(base.CountConversationEndpoints(dbObjectsNaming) == 0);
        }
Esempio n. 3
0
        public void Test()
        {
            var mapper = new ModelToTableMapper <DatabaseObjectAutoCleanUpAfterHugeInsertsTestSqlServerModel>();

            mapper.AddMapping(c => c.Name, "First Name").AddMapping(c => c.Surname, "Second Name");

            var tableDependency = new SqlTableDependencyTest <DatabaseObjectAutoCleanUpAfterHugeInsertsTestSqlServerModel>(
                ConnectionStringForTestUser,
                includeOldValues: true,
                tableName: TableName,
                mapper: mapper,
                stopWithoutDisposing: true);

            tableDependency.OnChanged += (o, args) => { };
            tableDependency.Start();
            var dbObjectsNaming = tableDependency.DataBaseObjectsNamingConvention;

            Thread.Sleep(5000);

            tableDependency.Stop();

            Thread.Sleep(1000);

            using (var sqlConnection = new SqlConnection(ConnectionStringForTestUser))
            {
                sqlConnection.Open();
                using (var sqlCommand = sqlConnection.CreateCommand())
                {
                    for (var i = 0; i < 10000; i++)
                    {
                        sqlCommand.CommandText = $"INSERT INTO [{TableName}] ([First Name], [Second Name]) VALUES ('{i}', '{i}')";
                        sqlCommand.ExecuteNonQuery();
                    }
                }
                sqlConnection.Close();
            }

            Thread.Sleep(1000 * 60 * 3);

            Assert.IsTrue(base.AreAllDbObjectDisposed(dbObjectsNaming));
            Assert.IsTrue(base.CountConversationEndpoints(dbObjectsNaming) == 0);
        }
        public void TestThrowExceptionInCreateSqlServerDatabaseObjects()
        {
            SqlTableDependencyTest <DatabaseObjectCleanUpTestSqlServerModel> tableDependency = null;
            string objectNaming = string.Empty;

            try
            {
                tableDependency = new SqlTableDependencyTest <DatabaseObjectCleanUpTestSqlServerModel>(
                    ConnectionStringForTestUser,
                    tableName: TableName,
                    throwExceptionCreateSqlServerDatabaseObjects: true);

                tableDependency.OnChanged += (sender, e) => { };
                objectNaming = tableDependency.DataBaseObjectsNamingConvention;
                tableDependency.Start();
            }
            catch
            {
            }

            Assert.IsTrue(base.AreAllDbObjectDisposed(objectNaming));
            Assert.IsTrue(base.CountConversationEndpoints(objectNaming) == 0);
        }