Example #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"));
        }
Example #2
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."));
        }
Example #3
0
        public static void DefaultTaskExists(ITaskBuilder builder, bool executed)
        {
            "Given a default task"
            .f(() => builder = ScriptCs.Require <Bau>().Do(() => executed = true));

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

            "Then the task is executed"
            .f(() => executed.Should().BeTrue());
        }
Example #4
0
        public static void ANonDefaultTaskExists(ITaskBuilder builder, Exception ex)
        {
            "Given no tasks"
            .f(() => builder = ScriptCs.Require <Bau>().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 default task was not found"
            .f(() => ex.Message.Should().Contain("'default' task not found"));
        }
Example #5
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());
        }
Example #6
0
        public static void ExecutingAnInlineTask(ITaskBuilder builder, bool executed)
        {
            "Given a default task with an inline task"
            .f(() => builder = ScriptCs.Require <Bau>().Do(() =>
            {
                var task = new BauCore.BauTask();
                task.Actions.Add(() => executed = true);
                task.Execute();
            }));

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

            "Then the inline task is executed"
            .f(() => executed.Should().BeTrue());
        }
Example #7
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"));
        }
Example #8
0
        public static void NonexistentDependency(ITaskBuilder builder, Exception ex)
        {
            "Given a default task with a non-existent dependency"
            .f(c => builder = ScriptCs.Require <Bau>()
                              .Task("default").DependsOn("non-existent")
                              .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"));
        }
Example #9
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());
        }
Example #10
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"));
        }
Example #11
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"));
        }
 public ScriptPack(ScriptCs.Contracts.ILogProvider loggerProvider, IControllerTypeManager typeManager)
 {
     _logger = loggerProvider.ForCurrentType();
     _typeManager = typeManager;
 }
 public ControllerTypeManager(ScriptCs.Contracts.ILogProvider loggerProvider)
 {
     _logger = loggerProvider.ForCurrentType();
 }