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

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

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

            fixture.GivenProcessExitsWithCode(1);

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

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

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

            // Then
            ExtraAssert.IsArgumentNullException(result, "settings");
        }
        public void Should_Throw_If_Process_Was_Not_Started()
        {
            // Given
            var fixture = new UniversalPackageUnpackerFixture();

            fixture.GivenProcessCannotStart();

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

            // Then
            ExtraAssert.IsCakeException(result, "UPack: Process was not started.");
        }
        public void Should_Throw_If_UPack_Executable_Was_Not_Found()
        {
            // Given
            var fixture = new UniversalPackageUnpackerFixture();

            fixture.GivenDefaultToolDoNotExist();

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

            // Then
            ExtraAssert.IsCakeException(result, "UPack: Could not locate executable.");
        }
        public void Should_Add_Overwrite_To_Arguments_If_Set(bool overwrite, string expected)
        {
            // Given
            var fixture = new UniversalPackageUnpackerFixture {
                Settings = { Overwrite = overwrite }
            };

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

            // Then
            Assert.Equal(expected, result.Args);
        }
        public void Should_Throw_If_Package_File_Does_Not_Exist()
        {
            // Given
            var fixture = new UniversalPackageUnpackerFixture {
                Settings = { Package = "./path/does/not/exist.upack" }
            };

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

            // Then
            ExtraAssert.IsCakeExceptionWithMessage(result, s => s.StartsWith("Universal package file does not exist at"));
        }
        public void Should_Use_UPack_Executable_From_Tool_Path_If_Provided(string toolPath, string expected)
        {
            // Given
            var fixture = new UniversalPackageUnpackerFixture {
                Settings = { ToolPath = toolPath }
            };

            fixture.GivenSettingsToolPathExist();

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

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