예제 #1
0
        public void SchemaRegistryCanRemoveOldRecords([ValueSource("ConnectionStrings")] string connectionString)
        {
            TestWithRollback(connectionString, connection =>
            {
                // create the registry
                SchemaRegistry registry = new SchemaRegistry(connection, TestSchemaGroup);

                // add an entry and save it to the database
                registry.Entries.Add(new SchemaRegistryEntry()
                {
                    SchemaGroup   = "test",
                    ObjectName    = "Beer",
                    Type          = SchemaObjectType.Table,
                    Signature     = "1234",
                    OriginalOrder = 1
                });
                registry.Commit();

                // create another registry and make sure it loads the entries
                registry = new SchemaRegistry(connection, TestSchemaGroup);
                Assert.AreEqual(1, registry.Entries.Count);

                // clear the entries
                registry.Entries.Clear();
                registry.Commit();

                // create another registry and make sure it loads the entries
                registry = new SchemaRegistry(connection, TestSchemaGroup);
                Assert.AreEqual(0, registry.Entries.Count);
            });
        }
예제 #2
0
        public void SchemaRegistryShouldNotExecuteSchemaUpdateInRecordOnlyMode([ValueSource("ConnectionStrings")] string connectionString)
        {
            TestWithRollback(connectionString, connection =>
            {
                // only script the data
                connection.ScriptOnly = true;

                // create the registry
                SchemaRegistry registry = new SchemaRegistry(connection, TestSchemaGroup);
                registry.Entries.Add(new SchemaRegistryEntry()
                {
                    SchemaGroup   = "test",
                    ObjectName    = "Beer",
                    Type          = SchemaObjectType.Table,
                    Signature     = "1234",
                    OriginalOrder = 1
                });
                registry.Commit();

                // we want to script the delete or insert into the registry, but not execute them in script mode
                Assert.IsTrue(connection.ScriptLog.ToString().Contains(String.Format("DELETE FROM [{0}]", SchemaRegistry.SchemaRegistryTableName)));
                Assert.IsTrue(connection.ScriptLog.ToString().Contains(String.Format("INSERT INTO [{0}]", SchemaRegistry.SchemaRegistryTableName)));
                Assert.IsFalse(connection.ExecutionLog.ToString().Contains(String.Format("DELETE FROM [{0}]", SchemaRegistry.SchemaRegistryTableName)));
                Assert.IsFalse(connection.ExecutionLog.ToString().Contains(String.Format("INSERT INTO [{0}]", SchemaRegistry.SchemaRegistryTableName)));
            });
        }