Пример #1
0
        public static void NestedDependencies(ITaskBuilder builder, List <string> executedTasks)
        {
            "Given a non-default task"
            .f(c => builder = ScriptCs.Require <Bau>()
                              .Task("non-default1")
                              .Do(() => (executedTasks = new List <string>()).Add("non-default1")));

            "And a second non-default task which depends on the first non-default task"
            .f(c => builder
               .Task("non-default2").DependsOn("non-default1")
               .Do(() => executedTasks.Add("non-default2")));

            "And a default task which depends on the second non-default task"
            .f(() => builder
               .Task("default").DependsOn("non-default2")
               .Do(() => executedTasks.Add("default")));

            "When I run the builder"
            .f(() => builder.Run());

            "Then all three tasks are executed"
            .f(() => executedTasks.Count.Should().Be(3));

            "And the first non-default task is executed first"
            .f(() => executedTasks[0].Should().Be("non-default1"));

            "And the second non-default task is executed second"
            .f(() => executedTasks[1].Should().Be("non-default2"));

            "And the default task is executed third"
            .f(() => executedTasks[2].Should().Be("default"));
        }
Пример #2
0
        public static void MultipleDependencies(ITaskBuilder builder, List<string> executedTasks)
        {
            "Given a non-default task"
                .f(c => builder = ScriptCs.Require<Bau>()
                    .Task("non-default1")
                        .Do(() => (executedTasks = new List<string>()).Add("non-default1")));

            "And a second non-default task"
                .f(() => builder
                    .Task("non-default2")
                        .Do(() => executedTasks.Add("non-default2")));

            "And a default task which depends on both non-default tasks"
                .f(() => builder
                    .Task("default").DependsOn("non-default1", "non-default2")
                        .Do(() => executedTasks.Add("default")));

            "When I run the builder"
                .f(() => builder.Run());

            "Then all three tasks are executed"
                .f(() => executedTasks.Count.Should().Be(3));

            "And the first non-default task is executed first"
                .f(() => executedTasks[0].Should().Be("non-default1"));

            "And the second non-default task is executed second"
                .f(() => executedTasks[1].Should().Be("non-default2"));

            "And the default task is executed third"
                .f(() => executedTasks[2].Should().Be("default"));
        }
Пример #3
0
        public static void DependencyFails(ITaskBuilder builder, bool defaultExecuted, Exception ex)
        {
            "And a non-default task which fails"
                .f(c => builder = ScriptCs.Require<Bau>()
                    .Task("non-default").DependsOn("default")
                        .Do(() =>
                        {
                            throw new Exception();
                        }));

            "And a default task which depends on the non-default task"
                .f(c => builder
                    .Task("default").DependsOn("non-default")
                        .Do(() => defaultExecuted = true));

            "When I run the builder"
                .f(() => ex = Record.Exception(() => builder.Run()));

            "Then execution should fail"
                .f(() => ex.Should().NotBeNull());

            "And the default task is not executed"
                .f(() => defaultExecuted.Should().BeFalse());

            "And I am informed that the non-default task was executed"
                .f(() => ex.Message.Should().Contain("'non-default' task failed."));
        }
Пример #4
0
        public static void DependencyFails(ITaskBuilder builder, bool defaultExecuted, Exception ex)
        {
            "And a non-default task which fails"
            .f(c => builder = ScriptCs.Require <Bau>()
                              .Task("non-default").DependsOn("default")
                              .Do(() =>
            {
                throw new Exception();
            }));

            "And a default task which depends on the non-default task"
            .f(c => builder
               .Task("default").DependsOn("non-default")
               .Do(() => defaultExecuted = true));

            "When I run the builder"
            .f(() => ex = Record.Exception(() => builder.Run()));

            "Then execution should fail"
            .f(() => ex.Should().NotBeNull());

            "And the default task is not executed"
            .f(() => defaultExecuted.Should().BeFalse());

            "And I am informed that the non-default task was executed"
            .f(() => ex.Message.Should().Contain("'non-default' task failed."));
        }
Пример #5
0
        public static void MultipleTasks(string[] args, ITaskBuilder builder, bool executed1, bool executed2)
        {
            "Given arguments containing 2 non-default tasks"
                .f(() => builder = ScriptCs.Require<Bau>(new[] { "non-default1", "non-default2" }));

            "And a non-default task"
                .f(() => builder.Task("non-default1").Do(() => executed1 = true));

            "And another non-default task"
                .f(() => builder.Task("non-default2").Do(() => executed2 = true));

            "When I run the builder"
                .f(() => builder.Run());

            "Then the first task is executed"
                .f(() => executed1.Should().BeTrue());

            "And the second task is executed"
                .f(() => executed2.Should().BeTrue());
        }
Пример #6
0
        public static void MultipleTasks(string[] args, ITaskBuilder builder, bool executed1, bool executed2)
        {
            "Given arguments containing 2 non-default tasks"
            .f(() => builder = ScriptCs.Require <Bau>(new[] { "non-default1", "non-default2" }));

            "And a non-default task"
            .f(() => builder.Task("non-default1").Do(() => executed1 = true));

            "And another non-default task"
            .f(() => builder.Task("non-default2").Do(() => executed2 = true));

            "When I run the builder"
            .f(() => builder.Run());

            "Then the first task is executed"
            .f(() => executed1.Should().BeTrue());

            "And the second task is executed"
            .f(() => executed2.Should().BeTrue());
        }
Пример #7
0
        public static void ReenablingATask(ITaskBuilder builder, List <string> executedTasks)
        {
            "Given a non-default task which depends on and reenables another non-default task"
            .f(c => builder = ScriptCs.Require <Bau>()
                              .Task("non-default").DependsOn("other-non-default")
                              .Do(() =>
            {
                builder.Reenable("other-non-default");
                executedTasks.Add("non-default");
            }));

            "And the other non-default task"
            .f(c => builder
               .Task("other-non-default")
               .Do(() => (executedTasks ?? (executedTasks = new List <string>())).Add("other-non-default")));

            "And a default task which depends on both non-default tasks"
            .f(() => builder
               .Task("default").DependsOn("non-default", "other-non-default")
               .Do(() => executedTasks.Add("default")));

            "When I run the builder"
            .f(() => builder.Run());

            "Then four tasks are executed"
            .f(() => executedTasks.Count.Should().Be(4));

            "And the other non-default task is executed first"
            .f(() => executedTasks[0].Should().Be("other-non-default"));

            "And the non-default task is executed second"
            .f(() => executedTasks[1].Should().Be("non-default"));

            "And the other non-default task is executed third for the second time"
            .f(() => executedTasks[2].Should().Be("other-non-default"));

            "And the default task is executed fourth"
            .f(() => executedTasks[3].Should().Be("default"));
        }
Пример #8
0
        public static void ReenablingATask(ITaskBuilder builder, List<string> executedTasks)
        {
            "Given a non-default task which depends on and reenables another non-default task"
                .f(c => builder = ScriptCs.Require<Bau>()
                    .Task("non-default").DependsOn("other-non-default")
                        .Do(() =>
                        {
                            builder.Reenable("other-non-default");
                            executedTasks.Add("non-default");
                        }));

            "And the other non-default task"
                .f(c => builder
                    .Task("other-non-default")
                        .Do(() => (executedTasks ?? (executedTasks = new List<string>())).Add("other-non-default")));

            "And a default task which depends on both non-default tasks"
                .f(() => builder
                    .Task("default").DependsOn("non-default", "other-non-default")
                        .Do(() => executedTasks.Add("default")));

            "When I run the builder"
                .f(() => builder.Run());

            "Then four tasks are executed"
                .f(() => executedTasks.Count.Should().Be(4));

            "And the other non-default task is executed first"
                .f(() => executedTasks[0].Should().Be("other-non-default"));

            "And the non-default task is executed second"
                .f(() => executedTasks[1].Should().Be("non-default"));

            "And the other non-default task is executed third for the second time"
                .f(() => executedTasks[2].Should().Be("other-non-default"));

            "And the default task is executed fourth"
                .f(() => executedTasks[3].Should().Be("default"));
        }
Пример #9
0
        public static void SingleTask(ITaskBuilder builder, bool executed)
        {
            "Given a non-default task is specified"
            .f(() => builder = ScriptCs.Require <Bau>(new[] { "non-default" }));

            "And a non-default task"
            .f(() => builder.Task("non-default").Do(() => executed = true));

            "When I run the builder"
            .f(() => builder.Run());

            "Then the task is executed"
            .f(() => executed.Should().BeTrue());
        }
Пример #10
0
        public static void AnotherTaskExists(ITaskBuilder builder, Exception ex)
        {
            "Given a non-existent task is specified"
                .f(() => builder = ScriptCs.Require<Bau>(new[] { "non-existent" }));

            "And another task exists"
                .f(() => builder.Task("foo").Do(() => { }));

            "When I run the builder"
                .f(() => ex = Record.Exception(() => builder.Run()));

            "Then execution should fail"
                .f(() => ex.Should().NotBeNull());

            "And I am informed that the non-existent task was not found"
                .f(() => ex.Message.Should().Contain("'non-existent' task not found"));
        }
Пример #11
0
        public static void AnotherTaskExists(ITaskBuilder builder, Exception ex)
        {
            "Given a non-existent task is specified"
            .f(() => builder = ScriptCs.Require <Bau>(new[] { "non-existent" }));

            "And another task exists"
            .f(() => builder.Task("foo").Do(() => { }));

            "When I run the builder"
            .f(() => ex = Record.Exception(() => builder.Run()));

            "Then execution should fail"
            .f(() => ex.Should().NotBeNull());

            "And I am informed that the non-existent task was not found"
            .f(() => ex.Message.Should().Contain("'non-existent' task not found"));
        }
Пример #12
0
        public static void CircularDependency(ITaskBuilder builder, List<string> executedTasks)
        {
            "Given a non-default task which depends on the default task"
                .f(c => builder = ScriptCs.Require<Bau>()
                    .Task("non-default").DependsOn("default")
                        .Do(() => (executedTasks = new List<string>()).Add("non-default")));

            "And a default task which depends on the non-default task"
                .f(c => builder
                    .Task("default").DependsOn("non-default")
                        .Do(() => executedTasks.Add("default")));

            "When I run the builder"
                .f(() => builder.Run());

            "Then both tasks are executed"
                .f(() => executedTasks.Count.Should().Be(2));

            "And the non-default task is executed first"
                .f(() => executedTasks[0].Should().Be("non-default"));

            "And the default task is executed second"
                .f(() => executedTasks[1].Should().Be("default"));
        }
Пример #13
0
        public static void SingleDependency(ITaskBuilder builder, List <string> executedTasks)
        {
            "Given a non-default task"
            .f(c => builder = ScriptCs.Require <Bau>()
                              .Task("non-default")
                              .Do(() => (executedTasks = new List <string>()).Add("non-default")));

            "And a default task which depends on the non-default task"
            .f(() => builder
               .Task("default").DependsOn("non-default")
               .Do(() => executedTasks.Add("default")));

            "When I run the builder"
            .f(() => builder.Run());

            "Then both tasks are executed"
            .f(() => executedTasks.Count.Should().Be(2));

            "And the non-default task is executed first"
            .f(() => executedTasks[0].Should().Be("non-default"));

            "And the default task is executed second"
            .f(() => executedTasks[1].Should().Be("default"));
        }
Пример #14
0
        public static void SingleTask(ITaskBuilder builder, bool executed)
        {
            "Given a non-default task is specified"
                .f(() => builder = ScriptCs.Require<Bau>(new[] { "non-default" }));

            "And a non-default task"
                .f(() => builder.Task("non-default").Do(() => executed = true));

            "When I run the builder"
                .f(() => builder.Run());

            "Then the task is executed"
                .f(() => executed.Should().BeTrue());
        }