public void Should_Find_TravisCI_Upload_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

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

                // Then
                Assert.Equal("/Working/tools/artifacts", result.Path.FullPath);
            }
            public void Should_Set_Working_Directory()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

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

                // Then
                Assert.Equal("/Working", result.Process.WorkingDirectory.FullPath);
            }
            public void Should_Add_Job_Id_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.JobId = "5";

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

                // Then
                Assert.Equal($"upload --job-id 5", result.Args);
            }
            public void Should_Add_Build_Number_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.BuildNumber = "5";

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

                // Then
                Assert.Equal($"upload --build-number 5", result.Args);
            }
            public void Should_Add_Save_Host_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.SaveHost = "hostname";

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

                // Then
                Assert.Equal($"upload --save-host hostname", result.Args);
            }
            public void Should_Add_Region_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Region = "N1-Q4";

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

                // Then
                Assert.Equal($"upload --s N1-Q4", result.Args);
            }
            public void Should_Add_Secret_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Secret = "secret";

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

                // Then
                Assert.Equal($"upload --secret [REDACTED]", result.Args);
            }
            public void Should_Add_Upload_Provider_If_Provided(string provider)
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.UploadProvider = provider;

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

                // Then
                Assert.Equal($"upload --upload-provider {provider}", result.Args);
            }
            public void Should_Add_Permissions_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Permissions = "admin";

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

                // Then
                Assert.Equal($"upload --permissions [REDACTED]", result.Args);
            }
            public void Should_Add_Cache_Control_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.CacheControl = Guid.NewGuid().ToString();

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

                // Then
                Assert.Equal($"upload --cache-control [REDACTED]", result.Args);
            }
            public void Should_Add_Bucket_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Bucket = Guid.NewGuid().ToString();

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

                // Then
                Assert.Equal($"upload --bucket {fixture.Settings.Bucket}", result.Args);
            }
            public void Should_Add_Key_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Key = Guid.NewGuid().ToString();

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

                // Then
                Assert.Equal($"upload --key [REDACTED]", result.Args);
            }
            public void Should_Add_Quiet_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Quiet = true;

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

                // Then
                Assert.Equal("upload --quiet", result.Args);
            }
            public void Should_Throw_If_Settings_Is_Null()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings = null;

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
            }
            public void Should_Add_Log_Information_If_Provided(string format)
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.LogFormat = format;

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

                // Then
                Assert.Equal($"upload --log-format {format}", result.Args);
            }
            public void Should_Add_Max_Size_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.MaxSize = "1048576001";

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

                // Then
                Assert.Equal($"upload --max-size 1048576001", result.Args);
            }
            public void Should_Add_Repository_Slug_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Slug = "slug";

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

                // Then
                Assert.Equal($"upload --repo-slug slug", result.Args);
            }
            public void Should_Add_Working_Directory_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.WorkingDirectory = "./";

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

                // Then
                Assert.Equal($"upload --working-dir \"/Working\"", result.Args);
            }
            public void Should_Add_Concurrency_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Concurrency = "5";

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

                // Then
                Assert.Equal($"upload --concurrency 5", result.Args);
            }
            public void Should_Add_Retries_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.Retries = 5;

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

                // Then
                Assert.Equal($"upload --retries 5", result.Args);
            }
            public void Should_Add_Auth_Token_If_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.AuthToken = "token";

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

                // Then
                Assert.Equal($"upload --auth-token [REDACTED]", result.Args);
            }
            public void Should_Throw_If_TravisCI_Upload_Runner_Was_Not_Found()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.GivenDefaultToolDoNotExist();

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("artifacts: Could not locate executable.", result?.Message);
            }
            public void Should_Use_TravisCI_Upload_Runner_From_Tool_Path_If_Provided(string toolPath, string expected)
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

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

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

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

                fixture.GivenProcessCannotStart();

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

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

                fixture.GivenProcessExitsWithCode(1);

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

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

                fixture.Settings.EnvironmentVariables = new Dictionary <string, string>
                {
                    { "ARTIFACTS_AUTH_TOKEN", "Token" }
                };

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

                // Then
                Assert.Equal("upload --auth-token [REDACTED]", result.Args);
            }
            public void Should_Add_Retries_If_Environment_Variable_Is_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.EnvironmentVariables = new Dictionary <string, string>
                {
                    { "ARTIFACTS_RETRIES", "5" }
                };

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

                // Then
                Assert.Equal("upload --retries 5", result.Args);
            }
            public void Should_Add_Target_Paths_If_Environment_Variable_Is_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.EnvironmentVariables = new Dictionary <string, string>
                {
                    { "ARTIFACTS_TARGET_PATHS", @"./source/cake:./source/travis" }
                };

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

                // Then
                Assert.Equal("upload --target-paths ./source/cake:./source/travis", result.Args);
            }
            public void Should_Add_Save_Host_If_Environment_Variable_Is_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.EnvironmentVariables = new Dictionary <string, string>
                {
                    { "ARTIFACTS_SAVE_HOST", "HOST" }
                };

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

                // Then
                Assert.Equal("upload --save-host HOST", result.Args);
            }
            public void Should_Add_Working_Directory_If_Environment_Variable_Is_Provided()
            {
                // Given
                var fixture = new TravisCIUploadRunnerFixture();

                fixture.Settings.EnvironmentVariables = new Dictionary <string, string>
                {
                    { "ARTIFACTS_WORKING_DIR", "./" }
                };

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

                // Then
                Assert.Equal("upload --working-dir \"/Working\"", result.Args);
            }