コード例 #1
0
            public void Should_Throw_If_Another_Task_With_The_Same_Name_Already_Been_Added_Regardless_Of_Casing()
            {
                // Given
                var engine = new CakeEngineFixture().CreateEngine();

                engine.Task("task");

                // When
                var result = Record.Exception(() => engine.Task("TASK"));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("Another task with the name 'TASK' has already been added.", result.Message);
            }
コード例 #2
0
            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]);
            }
コード例 #3
0
            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");
            }
コード例 #4
0
            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]);
            }
コード例 #5
0
            public void Should_Register_Created_Task()
            {
                // Given
                var engine = new CakeEngineFixture().CreateEngine();

                // When
                var result = engine.Task("task");

                // Then
                Assert.True(engine.Tasks.Contains(result.Task));
            }
コード例 #6
0
            public void Should_Return_A_New_Task()
            {
                // Given
                var engine = new CakeEngineFixture().CreateEngine();

                // When
                var result = engine.Task("task");

                // Then
                Assert.NotNull(result);
                Assert.Equal("task", result.Task.Name);
            }
コード例 #7
0
            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);
            }