示例#1
0
            public void Should_Throw_If_Dependency_Already_Exist()
            {
                // Given
                var task = new ActionTask("task");

                task.AddReverseDependency("other");

                // When
                var result = Record.Exception(() => task.AddReverseDependency("other"));

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("The task 'task' already is a dependee of 'other'.", result?.Message);
            }
示例#2
0
            public void Should_Add_Dependency_If_Not_Already_Present()
            {
                // Given
                var task = new ActionTask("task");

                // When
                task.AddReverseDependency("other");

                // Then
                Assert.Equal(1, task.Dependees.Count);
                Assert.Equal("other", task.Dependees[0].Name);
            }
示例#3
0
            public void Should_Not_Throw_When_An_Reverse_Dependency_Is_Depending_On_An_Optional_Task_That_Does_Not_Exist()
            {
                // Given
                var task = new ActionTask("A");

                task.AddReverseDependency("C", required: false);
                var tasks = new List <CakeTask> {
                    task
                };

                // When
                var result = Record.Exception(() => CakeGraphBuilder.Build(tasks));

                // Then
                Assert.Null(result);
            }
示例#4
0
            public void Should_Throw_When_Reverse_Dependency_Is_Depending_On_Task_That_Does_Not_Exist()
            {
                // Given
                var task = new ActionTask("A");

                task.AddReverseDependency("C");
                var tasks = new List <CakeTask> {
                    task
                };

                // When
                var result = Record.Exception(() => CakeGraphBuilder.Build(tasks));

                // Then
                Assert.NotNull(result);
                Assert.Equal("Task 'A' has specified that it's a dependency for task 'C' which does not exist.", result.Message);
            }
示例#5
0
            public void Should_Create_Edges_Between_Reversed_Dependencies()
            {
                // Given
                var task1 = new ActionTask("A");
                var task2 = new ActionTask("B");

                task2.AddReverseDependency("A");

                var graph = CakeGraphBuilder.Build(new List <CakeTask>
                {
                    task1, task2
                });

                // When
                var result = graph.Edges.SingleOrDefault();

                // Then
                Assert.NotNull(result);
                Assert.Equal("B", result.Start);
                Assert.Equal("A", result.End);
            }