Ejemplo n.º 1
0
        public void AddRunningEventToRunners()
        {
            List <string> taskNames = new List <string>();

            TaskRunner runner1 = new TaskRunner("Test1", () => { });
            TaskRunner runner2 = new TaskRunner("Test2", () => { });

            runners.AddRange(runner1, runner2);
            runners.AddRunningEventToRunners(x => taskNames.Add(x.TaskInfo.Name));
            runners.Run();

            taskNames.Should().Contain(runner1.TaskInfo.Name)
            .And.Contain(runner2.TaskInfo.Name)
            .And.HaveCount(2);
        }
Ejemplo n.º 2
0
        public void Run_IsStoppedIfFailIsFalse_CantExecuteAll()
        {
            List <string> taskNames = new List <string>();

            TaskRunner runner1 = new TaskRunner("Test1", () => {
                taskNames.Add("Test1");
            });
            TaskRunner runner2 = new TaskRunner("Test2", () => {
                taskNames.Add("Test2");
                throw new Exception("Test2");
            });
            TaskRunner runner3 = new TaskRunner("Test3", () => {
                taskNames.Add("Test3");
            });

            BulkTaskRunner runners = new BulkTaskRunner("BulkTest", true);

            runners.AddRange(runner1, runner2, runner3);

            Action actual = () => runners.Run();

            actual.Should().Throw <Exception>()
            .WithMessage("Test2");

            taskNames.Should()
            .Contain(runner1.TaskInfo.Name)
            .And.Contain(runner2.TaskInfo.Name)
            .And.NotContain(runner3.TaskInfo.Name)
            .And.HaveCount(2);
        }