public void Should_Set_Verbosity_If_Options_Are_Not_Null()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                // When
                fixture.RunApplication();

                // Then
                fixture.Log.Received(1).SetVerbosity(Verbosity.Diagnostic);
            }
Example #2
0
            public void Should_Create_Info_Command_If_Specified_In_Options()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options.ShowInfo = true;

                // When
                fixture.RunApplication();

                // Then
                fixture.CommandFactory.Received(1).CreateInfoCommand();
            }
Example #3
0
            public void Should_Throw_If_Options_Are_Null()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options = null;

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

                // Then
                AssertEx.IsArgumentNullException(result, "options");
            }
Example #4
0
            public void Should_Return_Error_If_No_Parameters_Are_Set()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options = new CakeOptions();

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

                // Then
                Assert.Equal(1, result);
            }
Example #5
0
            public void Should_Create_Build_Command_If_Options_Contain_Script()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options.Script = "./build.cake";

                // When
                fixture.RunApplication();

                // Then
                fixture.CommandFactory.Received(1).CreateBuildCommand();
            }
            public void Should_Not_Create_Dry_Run_Command_If_Options_Do_Not_Contain_Script()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options.PerformDryRun = true;

                // When
                fixture.RunApplication();

                // Then
                fixture.CommandFactory.Received(1).CreateHelpCommand();
            }
            public void Should_Return_Error_If_Options_Are_Null()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options = null;

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

                // Then
                Assert.Equal(1, result);
            }
            public void Should_Create_Help_Command_If_Options_Are_Null()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options = null;

                // When
                fixture.RunApplication();

                // Then
                fixture.CommandFactory.Received(1).CreateHelpCommand();
            }
Example #9
0
            public void Should_Create_Dry_Run_Command_If_Specified_In_Options()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options.PerformDryRun = true;
                fixture.Options.Script        = "./build.cake";

                // When
                fixture.RunApplication();

                // Then
                fixture.CommandFactory.Received(1).CreateDryRunCommand();
            }
Example #10
0
            public void Should_Create_Task_Tree_Command_If_Specified_In_Options()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options.ShowTree = true;
                fixture.Options.Script   = "./build.cake";

                // When
                fixture.RunApplication();

                // Then
                fixture.CommandFactory.Received(1).CreateTaskTreeCommand();
            }
Example #11
0
            public void Should_Create_Info_Command_Even_If_Script_Is_Specified()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options.Script   = "./build.cake";
                fixture.Options.ShowInfo = true;

                // When
                fixture.RunApplication();

                // Then
                fixture.CommandFactory.Received(0).CreateBuildCommand();
                fixture.CommandFactory.Received(1).CreateInfoCommand();
            }
            public void Should_Return_Failure_If_An_Exception_Was_Thrown()
            {
                // Given
                var fixture = new CakeApplicationFixture();

                fixture.Options.ShowHelp = true;
                fixture.CommandFactory.When(x => x.CreateHelpCommand())
                .Do(info => { throw new Exception("Error!"); });

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

                // Then
                Assert.Equal(1, result);
            }
Example #13
0
            public void Should_Return_Success_If_No_Exception_Was_Thrown()
            {
                // Given
                var fixture = new CakeApplicationFixture();
                var command = Substitute.For <ICommand>();

                command.Execute(fixture.Options).Returns(true);
                fixture.Options.Script = "./build.cake";
                fixture.CommandFactory.CreateBuildCommand().Returns(command);

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

                // Then
                Assert.Equal(0, result);
            }
Example #14
0
            public void Should_Throw_If_Command_Throws()
            {
                // Given
                var innerCommandError = new Exception("Inner command error");
                var fixture           = new CakeApplicationFixture();
                var command           = Substitute.For <ICommand>();

                command.Execute(fixture.Options).Throws(innerCommandError);
                fixture.CommandFactory.CreateBuildCommand().Returns(command);

                // When
                Exception actualError = Record.Exception(() => fixture.RunApplication());

                // Then
                Assert.Equal(innerCommandError, actualError);
            }