Ejemplo n.º 1
0
            public void Should_Set_The_Absolute_Output_File_Paths_In_Quotes_And_The_Urls_Of_The_Hosts_As_Arguments()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Hosts = new[]
                    {
                        new Uri("protocol://host/path"),
                        new Uri("protocol://anotherhost/path")
                    },
                    Settings =
                    {
                        OutputPaths = new FilePath[]
                        {
                            "output/file",
                            "output/anotherfile"
                        }
                    }
                };

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

                // Then
                Assert.Contains(
                    "-o \"/Working/output/file\" protocol://host/path",
                    result.Args);
                Assert.Contains(
                    "-o \"/Working/output/anotherfile\" protocol://anotherhost/path",
                    result.Args);
            }
Ejemplo n.º 2
0
            public void Should_Find_Curl_Runner_If_Tool_Path_Not_Provided()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture();

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

                // Then
                Assert.Equal("/Working/tools/curl", result.Path.FullPath);
            }
Ejemplo n.º 3
0
            public void Should_Set_The_Verbose_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { Verbose = true }
                };

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

                // Then
                Assert.Contains("--verbose", result.Args);
            }
Ejemplo n.º 4
0
            public void Should_Not_Set_The_User_Credentials_As_Argument_If_Username_Is_Null()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { Username = null, Password = "******" }
                };

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

                // Then
                Assert.DoesNotContain("--user", result.Args);
            }
Ejemplo n.º 5
0
            public void Should_Redact_The_User_Password_In_The_Safe_Arguments()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { Username = "******", Password = "******" }
                };

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

                // Then
                Assert.Contains("--user \"user:[REDACTED]\"", result.SafeArgs);
            }
Ejemplo n.º 6
0
            public void Should_Set_The_User_Credentials_In_Quotes_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { Username = "******", Password = "******" }
                };

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

                // Then
                Assert.Contains("--user \"user:password\"", result.Args);
            }
Ejemplo n.º 7
0
            public void Should_Set_The_Progress_Bar_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { ProgressBar = true }
                };

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

                // Then
                Assert.Contains("--progress-bar", result.Args);
            }
Ejemplo n.º 8
0
            public void Should_Not_Set_The_Fail_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { Fail = false }
                };

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

                // Then
                Assert.DoesNotContain("--fail", result.Args);
            }
Ejemplo n.º 9
0
            public void Should_Not_Set_The_ConnectTimeout_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { ConnectionTimeout = null }
                };

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

                // Then
                Assert.DoesNotContain("--connect-timeout", result.Args);
            }
Ejemplo n.º 10
0
            public void Should_Not_Set_The_MaxTime_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { MaxTime = null }
                };

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

                // Then
                Assert.DoesNotContain("--max-time", result.Args);
            }
Ejemplo n.º 11
0
            public void Should_Not_Set_The_RetryConnRefused_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { RetryOnConnectionRefused = false }
                };

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

                // Then
                Assert.DoesNotContain("--retry-connrefused", result.Args);
            }
Ejemplo n.º 12
0
            public void Should_Set_The_RetryMaxTime_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { RetryMaxTimeSeconds = 300 }
                };

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

                // Then
                Assert.Contains("--retry-max-time 300", result.Args);
            }
Ejemplo n.º 13
0
            public void Should_Set_The_Retry_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { RetryCount = 3 }
                };

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

                // Then
                Assert.Contains("--retry 3", result.Args);
            }
Ejemplo n.º 14
0
            public void Should_Not_Set_The_RetryDelay_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { RetryDelaySeconds = 0 }
                };

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

                // Then
                Assert.DoesNotContain("--retry-delay", result.Args);
            }
Ejemplo n.º 15
0
            public void Should_Throw_If_Curl_Executable_Was_Not_Found()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture();

                fixture.GivenDefaultToolDoNotExist();

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("curl: Could not locate executable.", result.Message);
            }
Ejemplo n.º 16
0
            public void Should_Set_The_Location_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { FollowRedirects = true }
                };

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

                // Then
                Assert.Contains("--location", result.Args);
            }
Ejemplo n.º 17
0
            public void Should_Set_The_Request_Command_In_Quotes_And_Upper_Case_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { RequestCommand = "Command" }
                };

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

                // Then
                Assert.Contains("--request \"COMMAND\"", result.Args);
            }
Ejemplo n.º 18
0
            public void Should_Not_Set_The_CreateDirs_Option_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { CreateDirectories = false }
                };

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

                // Then
                Assert.DoesNotContain("--create-dirs", result.Args);
            }
Ejemplo n.º 19
0
            public void Should_Throw_If_Settings_Is_Null()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture();

                fixture.Settings = null;

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

                // Then
                Assert.IsType <ArgumentNullException>(result);
                Assert.Equal("settings", ((ArgumentNullException)result).ParamName);
            }
Ejemplo n.º 20
0
            public void Should_Set_The_ConnectTimeout_Option_As_Argument()
            {
                // Given
                var connectionTimeout = TimeSpan.FromSeconds(5.5);
                var fixture           = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { ConnectionTimeout = connectionTimeout }
                };

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

                // Then
                Assert.Contains($"--connect-timeout {connectionTimeout.TotalSeconds}", result.Args);
            }
Ejemplo n.º 21
0
            public void Should_Throw_If_Hosts_Is_Empty()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture();

                fixture.Hosts = new Uri[0];

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

                // Then
                Assert.IsType <ArgumentException>(result);
                Assert.Equal("hosts", ((ArgumentException)result).ParamName);
                Assert.Contains("Hosts cannot be empty", ((ArgumentException)result).Message);
            }
Ejemplo n.º 22
0
            public void Should_Set_The_MaxTime_Option_As_Argument()
            {
                // Given
                var maxTime = TimeSpan.FromSeconds(2.37);
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings = { MaxTime = maxTime }
                };

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

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

                fixture.GivenSettingsToolPathExist();

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

                // Then
                Assert.Equal(expected, result.Path.FullPath);
            }
Ejemplo n.º 24
0
            public void Should_Set_The_Remote_Name_Switches_And_The_Urls_Of_The_Hosts_As_Arguments()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Hosts = new[]
                    {
                        new Uri("protocol://host/path"),
                        new Uri("protocol://anotherhost/path")
                    }
                };

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

                // Then
                Assert.Contains("-O protocol://host/path", result.Args);
                Assert.Contains("-O protocol://anotherhost/path", result.Args);
            }
Ejemplo n.º 25
0
            public void Should_Set_The_Headers_In_Quotes_As_Argument()
            {
                // Given
                var fixture = new CurlDownloadMultipleFilesFixture
                {
                    Settings =
                    {
                        Headers = new Dictionary <string, string>
                        {
                            ["name"] = "value"
                        }
                    }
                };

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

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