예제 #1
0
            public void Should_Throw_On_NonZero_ExitCode_Without_Custom_Validation()
            {
                // Given
                var fixture = new DummyToolFixture();

                fixture.GivenProcessExitsWithCode(11);

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

                // Then
                AssertEx.IsCakeException(result, "dummy: Process returned an error (exit code 11).");
            }
예제 #2
0
            public void Should_Succeed_On_Zero_ExitCode_Without_Custom_Validation()
            {
                // Given
                var fixture = new DummyToolFixture();

                fixture.GivenProcessExitsWithCode(0);

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

                // Then
                Assert.IsNotType <Exception>(result);
            }
예제 #3
0
            public void Should_Not_Throw_On_Invalid_ExitCode_When_HandleExitCode_Returns_True()
            {
                // Given
                var fixture = new DummyToolFixture();

                fixture.Settings.HandleExitCode = _ => true;
                fixture.GivenProcessExitsWithCode(10);

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

                // Then
                Assert.IsNotType <Exception>(result);
            }
예제 #4
0
파일: ToolTests.cs 프로젝트: gitfool/cake
            public void Executes_SetupProcessSettings()
            {
                var wasExecuted = false;

                // Given
                var fixture = new DummyToolFixture();

                fixture.Settings.SetupProcessSettings = (p) => wasExecuted = true;

                fixture.GivenProcessExitsWithCode(0);

                // When
                _ = fixture.Run();

                // Then
                Assert.True(wasExecuted);
            }
예제 #5
0
            public void Should_Throw_On_Invalid_ExitCode_Validated_By_Custom_Validator()
            {
                // Given
                var fixture = new DummyToolFixture();

                fixture.ExitCodeValidation = ec =>
                {
                    if (ec != 1)
                    {
                        throw new CakeException("UnitTest");
                    }
                };
                fixture.GivenProcessExitsWithCode(10);

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

                // Then
                AssertEx.IsCakeException(result, "UnitTest");
            }
예제 #6
0
            public void Should_Succeed_On_NonZero_ExitCode_Validated_By_Custom_Validator()
            {
                // Given
                var fixture = new DummyToolFixture();

                fixture.ExitCodeValidation = ec =>
                {
                    if (ec >= 10)
                    {
                        throw new CakeException("UnitTest");
                    }
                };
                fixture.GivenProcessExitsWithCode(7);

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

                // Then
                Assert.IsNotType <Exception>(result);
            }