Beispiel #1
0
        public void CanCreateSqlScriptThatIsNotSupportedInTransaction()
        {
            // arrange
            var version = 1;
            var description = "description";
            var sql = @"ALTER DATABASE [$database] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;";

            // act
            var sqlScript = new SqlScript(version, description, sql);

            // assert
            sqlScript.Version.Should().Be(version);
            sqlScript.Description.Should().Be(description);
            sqlScript.GetSqlBatches("$database", "dbo").Should().ContainSingle(batch => batch == sql);
            sqlScript.SupportedInTransaction.Should().BeFalse();
        }
Beispiel #2
0
        public void CanCreateSqlScript()
        {
            // arrange
            var version = 4;
            var description = "description";
            var sql = "PRINT 'test';";

            // act
            var sqlScript = new SqlScript(version, description, sql);

            // assert
            sqlScript.Version.Should().Be(version);
            sqlScript.Description.Should().Be(description);
            sqlScript.GetSqlBatches("$database", "dbo").Should().ContainSingle(batch => batch == sql);
            sqlScript.SupportedInTransaction.Should().BeTrue();
        }
Beispiel #3
0
        public void CanCreateSqlScriptWithSchemaCreation()
        {
            // arrange
            var version = 1;
            var description = "description";
            var sql = "PRINT 'test';";

            // act
            var sqlScript = new SqlScript(version, description, sql);

            // assert
            sqlScript.Version.Should().Be(version);
            sqlScript.Description.Should().Be(description);
            sqlScript.GetSqlBatches("$database", "dbo").Should().ContainInOrder(
                @"IF NOT EXISTS (SELECT * FROM information_schema.schemata WHERE schema_name = 'dbo')
    EXEC sp_executesql N'CREATE SCHEMA [dbo];';",
                sql);
            sqlScript.SupportedInTransaction.Should().BeTrue();
        }