public void Should_Throw_If_Settings_Are_Null()
        {
            var fixture = new StrongNameSignerRunnerFixture {
                Settings = null
            };

            Action result = () => fixture.Run();

            Assert.Throws <ArgumentNullException>(result);
        }
        public void Should_Set_Working_Directory()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture();

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

            // Then
            result.Process.WorkingDirectory.FullPath.Should().Be("/Working");
        }
        public void Should_Find_StrongNameSigner_Runner_If_Tool_Path_Not_Provided()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture();

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

            // Then
            result.Path.FullPath.Should().Be("/Working/tools/StrongNameSigner.Console.exe");
        }
        public void Should_Throw_If_StrongNameSigner_Executable_Was_Not_Found()
        {
            var fixture = new StrongNameSignerRunnerFixture();

            fixture.GivenDefaultToolDoNotExist();
            const string expectedMessage = "StrongNameSigner: Could not locate executable.";

            Action result = () => fixture.Run();

            var ex = Assert.Throws <CakeException>(result);

            Assert.Equal(expectedMessage, ex.Message);
        }
        public void Should_Set_LogLevel()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture {
                Settings = { LogLevel = StrongNameSignerVerbosity.Changes }
            };

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

            // Then
            result.Args.Should().Be("-l Changes");
        }
        public void Should_Set_OutputDirectory()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture {
                Settings = { OutputDirectory = "./output" }
            };

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

            // Then
            result.Args.Should().Be(@"-out ""/Working/output"" -l Silent");
        }
        public void Should_Set_Password()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture {
                Settings = { Password = "******" }
            };

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

            // Then
            result.Args.Should().Be(@"-p ""bob"" -l Silent");
        }
        public void Should_Set_KeyFile()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture {
                Settings = { KeyFile = "./test.snk" }
            };

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

            // Then
            result.Args.Should().Be(@"-k ""/Working/test.snk"" -l Silent");
        }
        public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture();

            fixture.GivenProcessExitsWithCode(1);

            // When
            Action result = () => fixture.Run();

            // Then
            result.Should().Throw <CakeException>().WithMessage("StrongNameSigner: Process returned an error (exit code 1).");
        }
        public void Should_Throw_If_Process_Was_Not_Started()
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture();

            fixture.GivenProcessCannotStart();

            // When
            Action result = () => fixture.Run();

            // Then
            result.Should().Throw <CakeException>().WithMessage("StrongNameSigner: Process was not started.");
        }
        public void Should_Use_StrongNameSigner_Runner_From_Tool_Path_If_Provided_On_Windows(string toolPath, string expected)
        {
            // Given
            var fixture = new StrongNameSignerRunnerFixture {
                Settings = { ToolPath = toolPath }
            };

            fixture.GivenSettingsToolPathExist();

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

            // Then
            result.Path.FullPath.Should().Be(expected);
        }