public void Should_Execute_Tasks_In_Correct_Order() { // Given var fixture = new CakeHostBuilderFixture(); fixture.RegisterTask <BuildTask>(); fixture.RegisterTask <CleanTask>(); fixture.RegisterTask <UnitTestsTask>(); fixture.UseExecutionStrategySubstitute(); fixture.Options.Target = "Run-Unit-Tests"; // When fixture.Run(); // Then Received.InOrder(() => { fixture.Strategy.Execute(Arg.Is <CakeTask>(t => t.Name == "Clean"), Arg.Any <ICakeContext>()); fixture.Strategy.Execute(Arg.Is <CakeTask>(t => t.Name == "Build"), Arg.Any <ICakeContext>()); fixture.Strategy.Execute(Arg.Is <CakeTask>(t => t.Name == "Run-Unit-Tests"), Arg.Any <ICakeContext>()); }); }
public void Should_Not_Execute_OnError_Method_If_Run_Completed() { // Given var fixture = new CakeHostBuilderFixture(); fixture.RegisterTask <OnErrorRunCompletedTask>(); fixture.Options.Target = "On-Error-Run-Completed"; // When fixture.Run(); // Then fixture.Log.DidNotReceive().Error("OnErrorRunCompletedTask Exception"); }
public void Should_Execute_OnError_Method_If_RunAsync_Failed() { // Given var fixture = new CakeHostBuilderFixture(); fixture.RegisterTask <OnErrorRunAsyncFailedTask>(); fixture.Options.Target = "On-Error-RunAsync-Failed"; // When fixture.Run(); // Then fixture.Log.Received(1).Error("An error has occurred. {0}", "On test exception"); }
public void Should_Abort_Build_If_Task_That_Is_Not_ContinueOnError_Throws() { // Given var fixture = new CakeHostBuilderFixture(); fixture.RegisterTask <NoContinueOnErrorTask>(); fixture.Options.Target = "No-Continue-On-Error"; // When var result = fixture.Run(); // Then Assert.NotEqual(0, result); }
public void Should_Throw_If_Dependency_Is_Not_A_Valid_Task() { // Given var fixture = new CakeHostBuilderFixture(); fixture.RegisterTask <InvalidDependencyTask>(); fixture.UseExecutionStrategySubstitute(); fixture.Options.Target = "InvalidDependencyTask"; // When var result = fixture.Run(); // Then Assert.Equal(1, result); fixture.Log.Received(1).Write( Verbosity.Quiet, LogLevel.Error, "Error: {0}", "The dependency DateTime does not implement IFrostingTask."); }
public void Should_Execute_Finally_Method_After_All_Methods() { // Given var fixture = new CakeHostBuilderFixture(); fixture.RegisterTask <FinallyTask>(); fixture.Options.Target = "Finally"; // When fixture.Run(); // Then Received.InOrder(() => { fixture.Log.Information("Run method called"); fixture.Log.Information("OnError method called"); fixture.Log.Information("Finally method called"); }); }
public static CakeHostBuilderFixture RegisterDefaultTask(this CakeHostBuilderFixture fixture) { fixture.RegisterTask <DummyTask>(); fixture.Options.Target = typeof(DummyTask).Name; return(fixture); }