Beispiel #1
0
            public void Should_Find_Curl_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new CurlUploadFileFixture();

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

                // Then
                Assert.Equal("/Working/tools/curl", result.Path.FullPath);
            }
Beispiel #2
0
            public void Should_Set_The_Request_Command_In_Quotes_And_Upper_Case_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { RequestCommand = "Command" }
                };

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

                // Then
                Assert.Contains("--request \"COMMAND\"", result.Args);
            }
Beispiel #3
0
            public void Should_Set_The_Verbose_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { Verbose = true }
                };

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

                // Then
                Assert.Contains("--verbose", result.Args);
            }
Beispiel #4
0
            public void Should_Set_The_Progress_Bar_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { ProgressBar = true }
                };

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

                // Then
                Assert.Contains("--progress-bar", result.Args);
            }
Beispiel #5
0
            public void Should_Redact_The_User_Password_In_The_Safe_Arguments()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { Username = "******", Password = "******" }
                };

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

                // Then
                Assert.Contains("--user \"user:[REDACTED]\"", result.SafeArgs);
            }
Beispiel #6
0
            public void Should_Not_Set_The_User_Credentials_As_Argument_If_Username_Is_Null()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { Username = null, Password = "******" }
                };

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

                // Then
                Assert.DoesNotContain("--user", result.Args);
            }
Beispiel #7
0
            public void Should_Set_The_User_Credentials_In_Quotes_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { Username = "******", Password = "******" }
                };

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

                // Then
                Assert.Contains("--user \"user:password\"", result.Args);
            }
Beispiel #8
0
            public void Should_Set_The_Url_Of_The_Host_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Host = new Uri("protocol://host/path")
                };

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

                // Then
                Assert.Contains("--url protocol://host/path", result.Args);
            }
Beispiel #9
0
            public void Should_Set_The_Absolute_Path_Of_The_File_To_Upload_In_Quotes_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    FilePath = "file/to/upload"
                };

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

                // Then
                Assert.Contains("--upload-file \"/Working/file/to/upload\"", result.Args);
            }
Beispiel #10
0
            public void Should_Not_Set_The_Location_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { FollowRedirects = false }
                };

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

                // Then
                Assert.DoesNotContain("--location", result.Args);
            }
Beispiel #11
0
            public void Should_Not_Set_The_Fail_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { Fail = false }
                };

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

                // Then
                Assert.DoesNotContain("--fail", result.Args);
            }
            public void Should_Throw_If_Host_Is_Null()
            {
                // Given
                var fixture = new CurlUploadFileFixture {
                    Host = null
                };

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("host", ((ArgumentNullException)result).ParamName);
            }
Beispiel #13
0
            public void Should_Not_Set_The_ConnectTimeout_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { ConnectionTimeout = null }
                };

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

                // Then
                Assert.DoesNotContain("--connect-timeout", result.Args);
            }
Beispiel #14
0
            public void Should_Throw_If_Curl_Executable_Was_Not_Found()
            {
                // Given
                var fixture = new CurlUploadFileFixture();

                fixture.GivenDefaultToolDoNotExist();

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("curl: Could not locate executable.", result.Message);
            }
Beispiel #15
0
            public void Should_Not_Set_The_MaxTime_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { MaxTime = null }
                };

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

                // Then
                Assert.DoesNotContain("--max-time", result.Args);
            }
Beispiel #16
0
            public void Should_Not_Set_The_RetryConnRefused_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { RetryOnConnectionRefused = false }
                };

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

                // Then
                Assert.DoesNotContain("--retry-connrefused", result.Args);
            }
Beispiel #17
0
            public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new CurlUploadFileFixture();

                fixture.Settings = null;

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("settings", ((ArgumentNullException)result).ParamName);
            }
Beispiel #18
0
            public void Should_Set_The_RetryMaxTime_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { RetryMaxTimeSeconds = 300 }
                };

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

                // Then
                Assert.Contains("--retry-max-time 300", result.Args);
            }
Beispiel #19
0
            public void Should_Not_Set_The_RetryDelay_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { RetryDelaySeconds = 0 }
                };

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

                // Then
                Assert.DoesNotContain("--retry-delay", result.Args);
            }
Beispiel #20
0
            public void Should_Set_The_Retry_Option_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { RetryCount = 3 }
                };

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

                // Then
                Assert.Contains("--retry 3", result.Args);
            }
Beispiel #21
0
            public void Should_Set_The_ConnectTimeout_Option_As_Argument()
            {
                // Given
                var connectionTimeout = TimeSpan.FromSeconds(5.5);
                var fixture           = new CurlUploadFileFixture
                {
                    Settings = { ConnectionTimeout = connectionTimeout }
                };

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

                // Then
                Assert.Contains(
                    $"--connect-timeout {connectionTimeout.TotalSeconds}",
                    result.Args);
            }
Beispiel #22
0
            public void Should_Set_The_MaxTime_Option_As_Argument()
            {
                // Given
                var maxTime = TimeSpan.FromSeconds(2.37);
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { MaxTime = maxTime }
                };

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

                // Then
                Assert.Contains(
                    $"--max-time {maxTime.TotalSeconds}",
                    result.Args);
            }
Beispiel #23
0
            public void Should_Use_Curl_Runner_From_Tool_Path_If_Provided(
                string toolPath,
                string expected)
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings = { ToolPath = toolPath }
                };

                fixture.GivenSettingsToolPathExist();

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

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
Beispiel #24
0
            public void Should_Set_The_Headers_In_Quotes_As_Argument()
            {
                // Given
                var fixture = new CurlUploadFileFixture
                {
                    Settings =
                    {
                        Headers = new Dictionary <string, string>
                        {
                            ["name"] = "value"
                        }
                    }
                };

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

                // Then
                Assert.Contains("--header \"name:value\"", result.Args);
            }