public void Should_Find_Sql_Package_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working/tools/SqlPackage.exe", result.Path.FullPath);
            }
            public void Should_Not_Add_Quiet_If_Not_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Action:DeployReport", result.Args);
            }
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Working", result.Process.WorkingDirectory.FullPath);
            }
            public void Should_Add_Variables_If_Provided(string key, string value)
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.Variables.Add(key, value);

                // When
                var result = fixture.Run();

                //Then
                Assert.Equal($"/Action:DeployReport /v:{key}={value}", result.Args);
            }
            public void Should_Not_Add_Target_Connection_If_Target_File_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.TargetFile = "./sqlDeployReportprofile.pubxml";

                // When
                var result = fixture.Run();

                // Then
                Assert.DoesNotContain("/TargetConnectionString:", result.Args);
            }
            public void Should_Add_Target_File_If_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.TargetFile = "./sqlDeployReportprofile.pubxml";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Action:DeployReport /TargetFile:\"/Working/sqlDeployReportprofile.pubxml\"", result.Args);
            }
            public void Should_Add_Quiet_If_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.Quiet = true;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Action:DeployReport /Quiet:True", result.Args);
            }
            public void Should_Add_Overwrite_Files_If_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.OverwriteFiles = true;

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Action:DeployReport /OverwriteFiles:True", result.Args);
            }
            public void Should_Add_OutputPath_If_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.OutputPath = "./artifacts";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Action:DeployReport /OutputPath:\"/Working/artifacts\"", result.Args);
            }
            public void Should_Throw_If_Settings_Is_Null()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings = null;

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <ArgumentNullException>(result);
            }
            public void Should_Use_Sql_Package_Runner_From_Tool_Path_If_Provided(string toolPath, string expected)
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.ToolPath = toolPath;
                fixture.GivenSettingsToolPathExist();

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.GivenProcessExitsWithCode(1);

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SqlPackage: Process returned an error (exit code 1).", result?.Message);
            }
            public void Should_Throw_If_Sql_Package_Runner_Was_Not_Found()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.GivenDefaultToolDoNotExist();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SqlPackage: Could not locate executable.", result?.Message);
            }
            public void Should_Add_Source_Connection_String_If_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.SourceConnectionString =
                    "Data Source=(LocalDB)\\v11.0;AttachDbFileName=|DataDirectory|\\DatabaseFileName.mdf;InitialCatalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True";

                // When
                var result = fixture.Run();

                // Then
                Assert.Equal("/Action:DeployReport /SourceConnectionString:\"Data Source=(LocalDB)\\v11.0;AttachDbFileName=|DataDirectory|\\DatabaseFileName.mdf;InitialCatalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True\"", result.Args);
            }
            public void Should_Add_Variables_After_Settings_If_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.OverwriteFiles = true;
                fixture.Settings.Variables.Add("CommandTimeout", "120");

                // When
                var result = fixture.Run();

                //Then
                Assert.Equal($"/Action:DeployReport /OverwriteFiles:True /v:CommandTimeout=120", result.Args);
            }
            public void Should_Not_Add_Target_File_If_Target_Connection_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.TargetConnectionString =
                    "Data Target=(LocalDB)\\v11.0;AttachDbFileName=|DataDirectory|\\DatabaseFileName.mdf;InitialCatalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True";

                // When
                var result = fixture.Run();

                // Then
                Assert.DoesNotContain("/TargetFile:", result.Args);
            }
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.GivenProcessCannotStart();

                // When
                var result = Record.Exception(() => fixture.Run());

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("SqlPackage: Process was not started.", result?.Message);
            }
            public void Should_Not_Add_Target_Properties_If_Target_File_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.TargetFile = "./sqlDeployReportprofile.pubxml";

                // When
                var result = fixture.Run();

                // Then
                Assert.DoesNotContain("/TargetConnectionString:", result.Args);
                Assert.DoesNotContain("/TargetDatabaseName:", result.Args);
                Assert.DoesNotContain("/TargetEncryptConnection:", result.Args);
                Assert.DoesNotContain("/TargetPassword:"******"/TargetServerName:", result.Args);
                Assert.DoesNotContain("/TargetTimeout:", result.Args);
                Assert.DoesNotContain("/TargetTrustServerCertificate:", result.Args);
                Assert.DoesNotContain("/TargetUser:", result.Args);
            }
            public void Should_Not_Add_Source_Properties_If_Source_Connection_Provided()
            {
                // Given
                var fixture = new SqlPackageDeployReportFixture();

                fixture.Settings.SourceConnectionString =
                    "Data Source=(LocalDB)\\v11.0;AttachDbFileName=|DataDirectory|\\DatabaseFileName.mdf;InitialCatalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True";

                // When
                var result = fixture.Run();

                // Then
                Assert.DoesNotContain("/SourceFile:", result.Args);
                Assert.DoesNotContain("/SourceDatabaseName:", result.Args);
                Assert.DoesNotContain("/SourceEncryptConnection:", result.Args);
                Assert.DoesNotContain("/SourcePassword:"******"/SourceServerName:", result.Args);
                Assert.DoesNotContain("/SourceTimeout:", result.Args);
                Assert.DoesNotContain("/SourceTrustServerCertificate:", result.Args);
                Assert.DoesNotContain("/SourceUser:", result.Args);
            }
Exemplo n.º 20
0
 public TheRunMethod()
 {
     fixture = new SqlPackageDeployReportFixture();
 }