public void Should_Throw_If_Package_Is_Null()
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { Package = null }
            };

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

            // Then
            Assert.IsCakeException(result, "Required setting Package not specified.");
        }
        public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture();

            fixture.GivenProcessExitsWithCode(1);

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

            // Then
            Assert.IsCakeException(result, "UPack: Process returned an error (exit code 1).");
        }
        public void Should_Throw_If_Settings_Are_Null()
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = null
            };

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

            // Then
            Assert.IsArgumentNullException(result, "settings");
        }
        public void Should_Throw_If_UPack_Executable_Was_Not_Found()
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture();

            fixture.GivenDefaultToolDoNotExist();

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

            // Then
            Assert.IsCakeException(result, "UPack: Could not locate executable.");
        }
        public void Should_Throw_If_Process_Was_Not_Started()
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture();

            fixture.GivenProcessCannotStart();

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

            // Then
            Assert.IsCakeException(result, "UPack: Process was not started.");
        }
        public void Should_Add_Overwrite_To_Arguments_If_Set(bool overwrite, string expected)
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { Overwrite = overwrite }
            };

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

            // Then
            Assert.Equal(expected, result.Args);
        }
        public void Should_Add_Credentials_To_Arguments_If_Set(string user, string pass, string expected)
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { UserName = user, Password = pass }
            };

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

            // Then
            Assert.Equal(expected, result.Args);
        }
        public void Should_Add_Version_To_Arguments_If_Set(string version, string expected)
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { Version = version }
            };

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

            // Then
            Assert.Equal(expected, result.Args);
        }
        public void Should_Throw_If_Credentials_Are_Not_Valid()
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { UserName = "******", Password = "" }
            };

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

            // Then
            Assert.IsCakeException(result, "Both username and password must be specified for authentication");
        }
        public void Should_Throw_If_Source_Is_Null_Or_Empty(string source)
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { Source = source }
            };

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

            // Then
            Assert.IsCakeException(result, "Required setting Source not specified.");
        }
        public void Should_Add_PreserveTimestamps_To_Arguments_If_Set(bool preserveTimestamps, string expected)
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { PreserveTimestamps = preserveTimestamps }
            };

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

            // Then
            Assert.Equal(expected, result.Args);
        }
        public void Should_Use_UPack_Executable_From_Tool_Path_If_Provided(string toolPath, string expected)
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { ToolPath = toolPath }
            };

            fixture.GivenSettingsToolPathExist();

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

            // Then
            Assert.Equal(expected, result.Path.FullPath);
        }