Esempio n. 1
0
            public void Should_Not_Add_Client_Id_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

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

                // Then
                Assert.Equal("/Action:Export", result.Args);
            }
Esempio n. 2
0
            public void Should_Find_Sql_Package_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

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

                // Then
                Assert.Equal("/Working/tools/SqlPackage.exe", result.Path.FullPath);
            }
Esempio n. 3
0
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

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

                // Then
                Assert.Equal("/Working", result.Process.WorkingDirectory.FullPath);
            }
Esempio n. 4
0
            public void Should_Add_Quiet_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings.Quiet = true;

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

                // Then
                Assert.Equal("/Action:Export /Quiet:True", result.Args);
            }
Esempio n. 5
0
            public void Should_Add_Overwrite_Files_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings.OverwriteFiles = true;

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

                // Then
                Assert.Equal("/Action:Export /OverwriteFiles:True", result.Args);
            }
Esempio n. 6
0
            public void Should_Add_OutputPath_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

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

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

                // Then
                Assert.Equal("/Action:Export /OutputPath:\"/Working/artifacts\"", result.Args);
            }
Esempio n. 7
0
            public void Should_Not_Add_Source_Connection_If_Source_File_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings.SourceFile = "./sqlpublishprofile.pubxml";

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

                // Then
                Assert.DoesNotContain("/SourceConnectionString:", result.Args);
            }
Esempio n. 8
0
            public void Should_Add_Target_File_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

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

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

                // Then
                Assert.Equal("/Action:Export /TargetFile:\"/Working/sqlpublishprofile.pubxml\"", result.Args);
            }
            public void Should_Add_Tenant_Id_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings.TenantId = "10";

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

                // Then
                Assert.Equal("/Action:Export /TenantId:10", result.Args);
            }
Esempio n. 10
0
            public void Should_Add_Properties_If_Provided(string key, string value)
            {
                // Given
                var fixture = new SqlPackageExportFixture();

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

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

                //Then
                Assert.Equal($"/Action:Export /p:{key}={value}", result.Args);
            }
Esempio n. 11
0
            public void Should_Throw_If_Settings_Is_Null()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings = null;

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
            }
Esempio n. 12
0
            public void Should_Not_Add_Source_File_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings.SourceFile = "./sqlpublishprofile.pubxml";

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

                // Then
                Assert.Equal("/Action:Export", result.Args);
            }
Esempio n. 13
0
            public void Should_Not_Add_Source_File_If_Source_Connection_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                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);
            }
Esempio n. 14
0
            public void Should_Use_Sql_Package_Runner_From_Tool_Path_If_Provided(string toolPath, string expected)
            {
                // Given
                var fixture = new SqlPackageExportFixture();

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

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

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
Esempio n. 15
0
            public void Should_Add_Properties_After_Settings_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings.UniversalAuthentication = true;
                fixture.Settings.Properties.Add("CommandTimeout", "120");

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

                //Then
                Assert.Equal($"/Action:Export /UniversalAuthentication:True /p:CommandTimeout=120", result.Args);
            }
Esempio n. 16
0
            public void Should_Not_Add_Target_Connection_String_If_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                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.Equal("/Action:Export", result.Args);
            }
Esempio n. 17
0
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.GivenProcessCannotStart();

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

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

                fixture.GivenDefaultToolDoNotExist();

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

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

                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);
            }
Esempio n. 20
0
            public void Should_Not_Add_Source_Properties_If_Source_File_Provided()
            {
                // Given
                var fixture = new SqlPackageExportFixture();

                fixture.Settings.SourceFile = "./sqlpublishprofile.pubxml";

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

                // Then
                Assert.DoesNotContain("/SourceConnectionString:", 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);
            }
 public TheRunMethod()
 {
     fixture = new SqlPackageExportFixture();
 }