예제 #1
0
            public void Should_Throw_If_Dependency_Already_Exist()
            {
                // Given
                var task = new CakeTask("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);
            }
예제 #2
0
        public void Should_Implement_ICakeTaskInfo()
        {
            // Given
            var task = new CakeTask("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.Select(x => x.Name).ToArray());
        }
예제 #3
0
            public void Should_Add_Dependency_If_Not_Already_Present()
            {
                // Given
                var task = new CakeTask("task");

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

                // Then
                Assert.Single(task.Dependencies);
                Assert.Equal("other", task.Dependencies[0].Name);
            }
예제 #4
0
            public void Should_Not_Throw_When_Depending_On_Optional_Task_That_Does_Not_Exist()
            {
                // Given
                var task = new CakeTask("A");

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

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

                // Then
                Assert.Null(result);
            }
예제 #5
0
            public void Should_Throw_When_Depending_On_Task_That_Does_Not_Exist()
            {
                // Given
                var task = new CakeTask("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);
            }
예제 #6
0
            public void Should_Create_Edges_Between_Dependencies()
            {
                // Given
                var task1 = new CakeTask("A");
                var task2 = new CakeTask("B");

                task2.AddDependency("A");

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

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

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