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

                task.AddDependency("other");

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

                // Then
                Assert.IsType <CakeException>(result);
                Assert.Equal("The task 'task' already have a dependency on 'other'.", result?.Message);
            }
Beispiel #2
0
        public void Should_Implement_ICakeTaskInfo()
        {
            // Given
            var task = new ActionTask("task");

            task.AddDependency("dependency1");
            task.AddDependency("dependency2");
            task.Description = "my description";

            // When
            ICakeTaskInfo result = task;

            // Then
            Assert.IsAssignableFrom <ICakeTaskInfo>(task);
            Assert.Equal("task", result.Name);
            Assert.Equal("my description", result.Description);
            Assert.Equal(new[] { "dependency1", "dependency2" }, result.Dependencies.ToArray());
        }
Beispiel #3
0
            public void Should_Add_Dependency_If_Not_Already_Present()
            {
                // Given
                var task = new ActionTask("task");

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

                // Then
                Assert.Equal(1, task.Dependencies.Count);
                Assert.Equal("other", task.Dependencies[0]);
            }
Beispiel #4
0
            public void Should_Throw_Exception_When_Depending_On_Task_That_Does_Not_Exist()
            {
                // Given
                var task = new ActionTask("A");

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

                // When
                var exception = Assert.Throws <CakeException>(() => CakeGraphBuilder.Build(tasks));

                // Then
                Assert.Equal("Task 'A' is dependent on task 'C' which do not exist.", exception.Message);
            }
Beispiel #5
0
            public void Should_Not_Throw_When_Depending_On_Optional_Task_That_Does_Not_Exist()
            {
                // Given
                var task = new ActionTask("A");

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

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

                // Then
                Assert.Null(result);
            }
Beispiel #6
0
            public void Should_Throw_When_Depending_On_Task_That_Does_Not_Exist()
            {
                // Given
                var task = new ActionTask("A");

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

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

                // Then
                Assert.NotNull(result);
                Assert.Equal("Task 'A' is dependent on task 'C' which does not exist.", result.Message);
            }
Beispiel #7
0
        public static IReadOnlyList <ICakeTaskInfo> CreateTasksWithDependencies()
        {
            var tasks = new List <ICakeTaskInfo>();
            var taskA = new ActionTask("A");
            var taskB = new ActionTask("B");
            var taskC = new ActionTask("C");
            var taskD = new ActionTask("D");

            taskB.AddDependency("A");
            taskC.AddDependency("B");
            taskD.AddDependency("A");

            tasks.Add(taskA);
            tasks.Add(taskB);
            tasks.Add(taskC);
            tasks.Add(taskD);

            return(tasks);
        }
Beispiel #8
0
            public void Should_Create_Edges_Between_Dependencies()
            {
                // Given
                var task1 = new ActionTask("A");
                var task2 = new ActionTask("B");

                task2.AddDependency("A");

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

                // When
                var result = graph.Edges.SingleOrDefault(x => x.Start == "A" && x.End == "B");

                // Then
                Assert.NotNull(result);
            }