public void Everything_Is_Ignored_Except_For_Schema_With_A_Negative_Filter() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'func') exec sp_executesql N'CREATE SCHEMA func';"); _gateway.RunQuery("IF object_id('func.funky') is null exec sp_executesql N'CREATE FUNCTION func.funky() RETURNS INT AS BEGIN RETURN 1; END';"); _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'blah') exec sp_executesql N'CREATE SCHEMA blah';"); _gateway.RunQuery("IF object_id('blah.funky_chicken') is null exec sp_executesql N'CREATE FUNCTION blah.funky_chicken() RETURNS INT AS BEGIN RETURN 1; END';"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(1, count); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky_chicken';"); Assert.AreEqual(1, count); var args = $"/Action:Publish /TargetServerName:(localdb)\\Filter /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True /p:AllowIncompatiblePlatform=true " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=IgnoreSchema!(func)\""; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(0, count, proc.Messages); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky_chicken';"); Assert.AreEqual(1, count, proc.Messages); }
public void Column_Is_Not_Dropped_When_Column_In_Dacpac_Is_Added() { _gateway.RunQuery( " exec sp_executesql N'drop table employees; create table Employees([EmployeeId] INT NOT NULL PRIMARY KEY, [ohwahweewah] varchar(max)); ';"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.columns where name = 'ohwahweewah';"); Assert.AreEqual(1, count); var args = $"/Action:Publish /TargetServerName:(localdb)\\Filter /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepTableColumns(Employees)\" /p:AllowIncompatiblePlatform=true /p:GenerateSmartDefaults=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.columns where name = 'ohwahweewah';"); Assert.AreEqual(1, count, proc.Messages); count = _gateway.GetInt( "SELECT COUNT(*) FROM sys.columns where name = 'Name' and object_id = object_id('Employees');"); Assert.AreEqual(1, count, proc.Messages); }
public void Everything_In_Schema_Is_Not_Dropped_When_Schema_Is_To_Keep() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'ohwahweewah') exec sp_executesql N'CREATE SCHEMA ohwahweewah';"); _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'BLAHHHkjkjk') exec sp_executesql N'CREATE TABLE ohwahweewah.BLAHHHkjkjk(id int)';"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.tables WHERE name = 'BLAHHHkjkjk';"); Assert.AreEqual(1, count); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.schemas where name = 'ohwahweewah';"); Assert.AreEqual(1, count); var args = "/Action:Publish /TargetServerName:localhost /SourceFile:DacPac.dacpac /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepSchema(ohwahweewah)\""; var proc = new ProcessGateway(".\\SqlPackage.exe\\SqlPackage.exe", args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.schemas where name = 'ohwahweewah';"); Assert.AreEqual(1, count, proc.Messages); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.tables WHERE name = 'BLAHHHkjkjk';"); Assert.AreEqual(1, count, proc.Messages); }
public void Column_Is_Not_Dropped_When_Columns_Are_ReOrdered() { _gateway.RunQuery( " exec sp_executesql N'IF EXISTS(SELECT * FROM SYS.TABLES WHERE NAME = ''Employees'') begin\r\n drop table employees;\r\nend \r\n create table Employees(name varchar(max), [EmployeeId] INT NOT NULL PRIMARY KEY, [ohwahweewah] varchar(max));';"); _gateway.RunQuery( " exec sp_executesql N'create trigger gh on Employees AFTER INSERT AS select 100';"); var count = _gateway.GetInt( "SELECT COUNT(*) FROM sys.columns where name = 'ohwahweewah' and object_id = object_id('Employees');"); Assert.AreEqual(1, count); var args = $"/Action:Publish /TargetServerName:localhost /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepTableColumns(Employees)\" /p:AllowIncompatiblePlatform=true /p:GenerateSmartDefaults=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt( "SELECT COUNT(*) FROM sys.columns where name = 'ohwahweewah' and object_id = object_id('Employees');"); Assert.AreEqual(1, count, proc.Messages); }
public void Negative_Filter_Excludes_Everything_Except_Specified_Schema_With_Additional_IgnoreSecurity_Also_Leaving_Security() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'func') exec sp_executesql N'CREATE SCHEMA func';"); _gateway.RunQuery("IF object_id('func.funky') is null exec sp_executesql N'CREATE FUNCTION func.funky() RETURNS INT AS BEGIN RETURN 1; END';"); _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'blah') exec sp_executesql N'CREATE SCHEMA blah';"); _gateway.RunQuery("IF object_id('blah.funky_chicken') is null exec sp_executesql N'CREATE FUNCTION blah.funky_chicken() RETURNS INT AS BEGIN RETURN 1; END';"); _gateway.RunQuery("IF NOT EXISTS(SELECT * FROM sys.database_principals WHERE name = 'fred') CREATE USER fred WITHOUT LOGIN;"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(1, count); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky_chicken';"); Assert.AreEqual(1, count); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'fred';"); Assert.AreEqual(1, count); var xmlDefinitionFileText = "<Filters><Filter Operation=\"Keep\" Type=\"Schema\" MatchType=\"DoesNotMatch\">func</Filter>" + "<Filter Operation=\"Ignore\" Type=\"Security\" MatchType=\"DoesMatch\"/></Filters>"; var xmlFile = Path.Combine(Environment.CurrentDirectory, "XmlMultiFilterTestsNegative_Filter_Excludes_Everything_Except_Specified_Schema_With_Additional_IgnoreSecurity_Also_Leaving_Security.xml"); if (File.Exists(xmlFile)) { File.Delete(xmlFile); } var sr = new StreamWriter(xmlFile); sr.Write(xmlDefinitionFileText); sr.Dispose(); var args = string.Format( $"/Action:Publish /TargetServerName:localhost /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=SqlPackageLogging=Info;\"SqlPackageXmlFilterFile={0}\" /p:AllowIncompatiblePlatform=true", xmlFile); var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(0, count, proc.Messages); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky_chicken';"); Assert.AreEqual(1, count, proc.Messages); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'fred';"); Assert.AreEqual(1, count, proc.Messages); }
public void Schema_Is_Not_Created_When_Name_Is_Ignored() { _gateway.RunQuery("IF EXISTS (SELECT * FROM sys.tables WHERE name = 'Employees')\r\nBEGIN DROP table dbo.Employees\r\nEND;"); var args = $"/Action:Publish /TargetServerName:(localdb)\\Filter /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor /p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=IgnoreSchema(dbo)\" /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True /p:AllowIncompatiblePlatform=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); var tableCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.tables where name = 'Employees';"); Assert.AreEqual(0, tableCount, proc.Messages); }
public void Schema_Is_Not_Created_When_Name_Is_Ignored() { _gateway.RunQuery("IF EXISTS (SELECT * FROM sys.tables WHERE name = 'Employees')\r\nBEGIN DROP table dbo.Employees\r\nEND;"); var args = "/Action:Publish /TargetServerName:localhost /SourceFile:DacPac.dacpac /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor /p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=IgnoreSchema(dbo)\" /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True"; var proc = new ProcessGateway(".\\SqlPackage.exe\\SqlPackage.exe", args); proc.Run(); var tableCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.tables where name = 'Employees';"); Assert.AreEqual(0, tableCount, proc.Messages); }
public void Schema_Is_Not_Dropped_When_Name_Is_Ignored() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'blah') exec sp_executesql N'CREATE SCHEMA blah';"); _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'bloobla') exec sp_executesql N'CREATE table blah.bloobla(id int)';"); var args = "/Action:Publish /TargetServerName:localhost /SourceFile:DacPac.dacpac /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor /p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=IgnoreSchema(blah)\" /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True"; var proc = new ProcessGateway(".\\SqlPackage.exe\\SqlPackage.exe", args); proc.Run(); proc.WasDeploySuccess(); var tableCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.schemas where name = 'blah';"); Assert.AreEqual(1, tableCount, proc.Messages); }
public void Schema_Is_Not_Dropped_When_Name_Is_Ignored() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'blah') exec sp_executesql N'CREATE SCHEMA blah';"); _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'bloobla') exec sp_executesql N'CREATE table blah.bloobla(id int)';"); var args = $"/Action:Publish /TargetServerName:(localdb)\\Filter /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor /p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=IgnoreSchema(blah)\" /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True /p:AllowIncompatiblePlatform=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); var tableCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.schemas where name = 'blah';"); Assert.AreEqual(1, tableCount, proc.Messages); }
public void Stored_Procedures_Are_Dropped_When_Objects_Ignored_And_Schema_Does_Not_Matchs() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.procedures WHERE name = 'proc_to_drop' AND SCHEMA_NAME(schema_id) = 'dbo')\r\nBEGIN exec sp_executesql N'create procedure [dbo].[proc_to_drop] as select 1;'\r\nEND;"); var procCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.procedures where name = 'proc_to_drop' AND SCHEMA_NAME(schema_id) = 'dbo';"); Assert.AreEqual(1, procCount); var args = $"/Action:Publish /TargetServerName:localhost /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor /p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=IgnoreType(.*Proced.*, guest)\" /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True /p:AllowIncompatiblePlatform=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); procCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.procedures where name = 'proc_to_drop' AND SCHEMA_NAME(schema_id) = 'dbo';"); Assert.AreEqual(0, procCount, proc.Messages); }
public void Stored_Procedures_Are_Ignored_When_Objects_Ignored() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.procedures WHERE name = 'proc_to_ignore')\r\nBEGIN exec sp_executesql N'create procedure proc_to_ignore as select 1;'\r\nEND;"); var procCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.procedures where name = 'proc_to_ignore';"); Assert.AreEqual(1, procCount); var args = "/Action:Publish /TargetServerName:localhost /SourceFile:DacPac.dacpac /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor /p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=IgnoreType(.*Proced.*)\" /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True"; var proc = new ProcessGateway(".\\SqlPackage.exe\\SqlPackage.exe", args); proc.Run(); procCount = _gateway.GetInt("SELECT COUNT(*) FROM sys.procedures where name = 'proc_to_ignore';"); Assert.AreEqual(1, procCount, proc.Messages); }
public void Keeps_Users_And_Roles() { _gateway.RunQuery("IF NOT EXISTS(SELECT * FROM sys.database_principals WHERE name = 'kjkjkjkj') CREATE USER [kjkjkjkj] WITHOUT LOGIN;"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'kjkjkjkj';"); Assert.AreEqual(1, count); var args = "/Action:Publish /TargetServerName:localhost /SourceFile:DacPac.dacpac /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepSecurity\""; var proc = new ProcessGateway(".\\SqlPackage.exe\\SqlPackage.exe", args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'kjkjkjkj';"); Assert.AreEqual(1, count, proc.Messages); }
public void Keeps_Users_And_Roles() { _gateway.RunQuery("IF NOT EXISTS(SELECT * FROM sys.database_principals WHERE name = 'kjkjkjkj') CREATE USER [kjkjkjkj] WITHOUT LOGIN;"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'kjkjkjkj';"); Assert.AreEqual(1, count); var args = $"/Action:Publish /TargetServerName:(localdb)\\Filter /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepSecurity\" /p:AllowIncompatiblePlatform=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'kjkjkjkj';"); Assert.AreEqual(1, count, proc.Messages); }
public void ObjectType_Is_Not_Dropped_When_Filter_Is_To_Keep() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.objects WHERE name = 'funky') exec sp_executesql N'CREATE FUNCTION funky() RETURNS INT AS BEGIN RETURN 1; END';"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(1, count); var args = "/Action:Publish /TargetServerName:localhost /SourceFile:DacPac.dacpac /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepType(ScalarFunction)\""; var proc = new ProcessGateway(".\\SqlPackage.exe\\SqlPackage.exe", args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(1, count, proc.Messages); }
public void ObjectType_Is_Not_Dropped_When_Filter_Is_To_Keep() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.objects WHERE name = 'funky') exec sp_executesql N'CREATE FUNCTION funky() RETURNS INT AS BEGIN RETURN 1; END';"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(1, count); var args = $"/Action:Publish /TargetServerName:(localdb)\\Filter /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepType(ScalarFunction)\" /p:AllowIncompatiblePlatform=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(1, count, proc.Messages); }
public void Column_Is_Not_Dropped_When_Name_Is_To_Keep_And_Constraint_Is_Dropped() { //exec sp_executesql N'alter table Employees add constraint [cs_abcd] check (Name like ''%%''); ' _gateway.RunQuery( "IF NOT EXISTS (select * from sys.objects where name = 'cs_abcd') exec sp_executesql N'alter table Employees add constraint [cs_abcd] check (Name like ''%%'');';"); var count = _gateway.GetInt("select COUNT(*) from sys.objects where name = 'cs_abcd';"); Assert.AreEqual(1, count); var args = $"/Action:Publish /TargetServerName:localhost /SourceFile:{Path.Combine(TestContext.CurrentContext.TestDirectory, "Dacpac.Dacpac")} /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter=KeepTableColumns(Employees)\" /p:AllowIncompatiblePlatform=true"; var proc = new ProcessGateway(Path.Combine(TestContext.CurrentContext.TestDirectory, "SqlPackage.exe\\SqlPackage.exe"), args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("select COUNT(*) from sys.objects where name = 'cs_abcd';"); Assert.AreEqual(0, count, proc.Messages); }
public void Negative_Filter_Excludes_Everything_Except_Specified_Schema_With_Additional_IgnoreSecurity_Also_Leaving_Security() { _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'func') exec sp_executesql N'CREATE SCHEMA func';"); _gateway.RunQuery("IF object_id('func.funky') is null exec sp_executesql N'CREATE FUNCTION func.funky() RETURNS INT AS BEGIN RETURN 1; END';"); _gateway.RunQuery("IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'blah') exec sp_executesql N'CREATE SCHEMA blah';"); _gateway.RunQuery("IF object_id('blah.funky_chicken') is null exec sp_executesql N'CREATE FUNCTION blah.funky_chicken() RETURNS INT AS BEGIN RETURN 1; END';"); _gateway.RunQuery("IF NOT EXISTS(SELECT * FROM sys.database_principals WHERE name = 'fred') CREATE USER fred WITHOUT LOGIN;"); var count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(1, count); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky_chicken';"); Assert.AreEqual(1, count); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'fred';"); Assert.AreEqual(1, count); var args = "/Action:Publish /TargetServerName:localhost /SourceFile:DacPac.dacpac /p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor " + " /TargetDatabaseName:Filters /p:DropObjectsNotInSource=True " + "/p:AdditionalDeploymentContributorArguments=\"SqlPackageFilter1=IgnoreSchema!(func)\";\"SqlPackageFilter2=IgnoreSecurity\";"; var proc = new ProcessGateway(".\\SqlPackage.exe\\SqlPackage.exe", args); proc.Run(); proc.WasDeploySuccess(); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky';"); Assert.AreEqual(0, count, proc.Messages); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.objects where name = 'funky_chicken';"); Assert.AreEqual(1, count, proc.Messages); count = _gateway.GetInt("SELECT COUNT(*) FROM sys.database_principals WHERE name = 'fred';"); Assert.AreEqual(1, count); }