public void Should_Throw_If_Settings_Are_Null()
            {
                // Given
                var fixture = new DotNetCoreNuGetAddSourceFixture();

                fixture.Settings = null;

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

                // Then
                AssertEx.IsArgumentNullException(result, "settings");
            }
            public void Should_Throw_If_Name_Is_Null_Or_WhiteSpace(string name)
            {
                // Given
                var fixture = new DotNetCoreNuGetAddSourceFixture();

                fixture.Name = name;

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

                // Then
                AssertEx.IsArgumentException(result, "name", "Value cannot be null or whitespace.");
            }
            public void Should_Add_Host_Arguments()
            {
                // Given
                var fixture = new DotNetCoreNuGetAddSourceFixture();

                fixture.Settings = new DotNetCoreNuGetSourceSettings {
                    DiagnosticOutput = true, Source = "source"
                };

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

                // Then
                Assert.Equal("--diagnostics nuget add source \"source\" --name \"name\"", result.Args);
            }
            public void Should_Add_Mandatory_Arguments()
            {
                // Given
                var fixture = new DotNetCoreNuGetAddSourceFixture();

                fixture.Settings = new DotNetCoreNuGetSourceSettings {
                    Source = "source"
                };

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

                // Then
                Assert.Equal("nuget add source \"source\" --name \"name\"", result.Args);
            }
            public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
            {
                // Given
                var fixture = new DotNetCoreNuGetAddSourceFixture();

                fixture.Settings = new DotNetCoreNuGetSourceSettings {
                    Source = "source"
                };
                fixture.GivenProcessExitsWithCode(1);

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

                // Then
                AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1).");
            }
            public void Should_Throw_If_Process_Was_Not_Started()
            {
                // Given
                var fixture = new DotNetCoreNuGetAddSourceFixture();

                fixture.Settings = new DotNetCoreNuGetSourceSettings {
                    Source = "source"
                };
                fixture.GivenProcessCannotStart();

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

                // Then
                AssertEx.IsCakeException(result, ".NET CLI: Process was not started.");
            }
            public void Should_Add_Additional_Arguments()
            {
                // Given
                var fixture = new DotNetCoreNuGetAddSourceFixture();

                fixture.Settings = new DotNetCoreNuGetSourceSettings
                {
                    Source   = "source",
                    UserName = "******",
                    Password = "******",
                    StorePasswordInClearText = true,
                    ValidAuthenticationTypes = "basic,negotiate"
                };

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

                // Then
                Assert.Equal("nuget add source \"source\" --name \"name\" --username \"username\" --password \"password\" --store-password-in-clear-text --valid-authentication-types \"basic,negotiate\"", result.Args);
            }