public void Should_Catch_Exceptions_If_Explicitly_Told_So() { // Given var engine = new CakeEngineFixture().CreateEngine(); engine.Task("A").ContinueOnError().Does(() => { throw new InvalidOperationException(); }); // When, Then engine.RunTarget("A"); }
public void Should_Throw_If_Target_Was_Not_Found() { // Given var engine = new CakeEngineFixture().CreateEngine(); // When var result = Record.Exception(() => engine.RunTarget("Run-Some-Tests")); // Then Assert.IsType <CakeException>(result); Assert.Equal("The target 'Run-Some-Tests' was not found.", result.Message); }
public void Should_Not_Catch_Exceptions_From_Task_If_Not_Explicitly_Told_So() { // Given var engine = new CakeEngineFixture().CreateEngine(); engine.Task("A").Does(() => { throw new InvalidOperationException("Whoopsie"); }); // When var result = Record.Exception(() => engine.RunTarget("A")); // Then Assert.IsType <InvalidOperationException>(result); Assert.Equal("Whoopsie", result.Message); }
public void Should_Skip_Tasks_Where_Criterias_Are_Not_Fulfilled() { // Given var result = new List <string>(); var engine = new CakeEngineFixture().CreateEngine(); engine.Task("A").Does(() => result.Add("A")); engine.Task("B").IsDependentOn("A").WithCriteria(() => false).Does(() => result.Add("B")); engine.Task("C").IsDependentOn("B").Does(() => result.Add("C")); // When engine.RunTarget("C"); // Then Assert.Equal(2, result.Count); Assert.Equal("A", result[0]); Assert.Equal("C", result[1]); }
public void Should_Execute_Tasks_In_Order() { // Given var result = new List <string>(); var engine = new CakeEngineFixture().CreateEngine(); engine.Task("A").Does(() => result.Add("A")); engine.Task("B").IsDependentOn("A").Does(() => result.Add("B")); engine.Task("C").IsDependentOn("B").Does(() => result.Add("C")); // When engine.RunTarget("C"); // Then Assert.Equal(3, result.Count); Assert.Equal("A", result[0]); Assert.Equal("B", result[1]); Assert.Equal("C", result[2]); }