Ejemplo n.º 1
0
        public void Workflow_Add_adds_multiple_IExecutables_to_taskList()
        {
            var work  = new Workflow();
            var task1 = new SplineReticulator("curvilinear");
            var task2 = new VirtualAudioMode("Silent");

            work.Add(task1);
            work.Add(task2);
            var result = work.GetTaskList();

            result[0].Should().Be(task1);
            result[1].Should().Be(task2);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var workflow = new Workflow();

            workflow.Add(new CallWebService());
            workflow.Add(new ChangeStatusInDatabase());
            workflow.Add(new SendEmail());
            workflow.Add(new UploadVideoToCloud());

            var workflowEngine = new WorkflowEngine();

            workflowEngine.Run(workflow);
        }
Ejemplo n.º 3
0
        public async Task WorkflowEngine_Run_runs_all_tasks_with_correct_parameters(string param1, string param2)
        {
            var work = new Workflow();

            work.Add(new SplineReticulator(param1));
            work.Add(new VirtualAudioMode(param2));
            work.Add(new VirtualAudioSystem());

            var result = await GetOutputFor(WorkflowEngine.Run, work);

            result.Should().ContainAll($"using {param1} covariant basis",
                                       $"Virtual audio system succesfully set to {param2} mode", "Virtual audio system is running.");
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var workflow = new Workflow();

            workflow.Add(new UploadVideo());
            workflow.Add(new NotifyWebService());
            workflow.Add(new NotifyVideoOwner());
            workflow.Add(new UpdateDatabase());

            var workflowEngine = new WorkFlowEngine();

            workflowEngine.Run(workflow);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var workFlow = new Workflow();
            workFlow.Add(new Upload());
            workFlow.Add(new ReadyForEncodingNotifier());
            workFlow.Add(new SendMail());
            workFlow.Add(new DbInformer());

            var workFlowEngine = new WorkflowEngine();
            workFlowEngine.Run(workFlow);

            System.Console.ReadLine();
        } 
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var workflow = new Workflow();

            workflow.Add(new CallWebService());
            workflow.Add(new ChangeStatus());
            workflow.Add(new SendEMail());
            workflow.Add(new UploadVideo());

            var engine = new WorkflowEngine();

            engine.Run(workflow);
        }
Ejemplo n.º 7
0
        public async Task Workflow_LogContents_logs_all_tasks()
        {
            var work = new Workflow();

            work.Add(new SplineReticulator("curvilinear"));
            work.Add(new VirtualAudioMode("Silent"));
            work.Add(new VirtualAudioSystem());

            var result = await GetOutputFor(work.LogContents);

            result.Should().ContainAll("SplineReticulator(curvilinear)",
                                       "VirtualAudioMode(Silent)",
                                       "VirtualAudioSystem()");
        }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.I))
        {
            Workflow workflow = new Workflow();

            workflow.Add(new VideoUploader());
            workflow.Add(new CallWebService());
            workflow.Add(new SendEmail());
            workflow.Add(new ChangeStatus());

            engine.Run(workflow);
        }
    }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            var Workflow workFlow = new Workflow();

            workFlow.Add(new VideoUploader());
            workFlow.Add(new CallWebService());
            workFlow.Add(new SendEmail());
            workFlow.Add(new ChangeStatus());

            var engine = new WorkFlowEngine();

            engine.Run(workFlow);

            Console.ReadLine();
        }
Ejemplo n.º 10
0
        public void Should_Throw_If_Step_Included_More_Than_Once()
        {
            Workflow.Add <TestStep>();
            Action addStep = () => Workflow.Add <TestStep>();

            addStep.ShouldThrow <StepAlreadyIncludedException>();
        }
Ejemplo n.º 11
0
        public void Should_Not_Rollback_Steps_If_Succeeded()
        {
            Workflow.Add <RollbackStep>();
            Workflow.Execute(Context);

            Context.Out.DidNotReceive().Rollback(Arg.Any <RollbackStep>());
        }
Ejemplo n.º 12
0
        public void Workflow_Remove_removes_task_from_taskList()
        {
            var work  = new Workflow();
            var task1 = new SplineReticulator("curvilinear");

            work.Add(task1);
            var task2 = new VirtualAudioMode("Silent");

            work.Add(task2);
            work.Remove(task2);

            var result = work.GetTaskList();

            result.Should().NotContain(task2);
            result.Should().Contain(task1);
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            var work = new Workflow();

            work.Add(new SplineReticulator("curvilinear"));
            work.Add(new VirtualAudioMode("silent"));
            work.Add(new VirtualAudioSystem());
            var task = new VirtualAudioMode("invisible");

            work.Add(task);

            work.LogContents();
            work.Remove(task);

            WorkflowEngine.Run(work);
            work.LogContents();
        }
Ejemplo n.º 14
0
        public void Should_Execute_Step()
        {
            Workflow.Add <TestStep>();

            Workflow.Execute(Context);

            Workflow.PassedSteps.Should().HaveCount(1);
        }
Ejemplo n.º 15
0
        public void Should_Add_Steps_To_Failed_If_Step_Invoked_Fail_Method()
        {
            Workflow.Add <FailingStep>();

            Workflow.Execute(Context);

            Workflow.FailedSteps.Should().HaveCount(1);
        }
Ejemplo n.º 16
0
        public void Should_Throw_If_Required_Step_Not_Included()
        {
            Workflow.Add <DependentStep>();

            Action exec = () => Workflow.Execute(Context);

            exec.ShouldThrow <MissingRequiredStepException>();
        }
Ejemplo n.º 17
0
        public void Failure_Handler_Should_Not_Invoke_On_Success()
        {
            Workflow.Add <TestStep>();
            Workflow.OnCrash((step, ctx, ex) => ctx.Out.Failed(ex));

            Workflow.Execute(Context);

            Context.Out.DidNotReceive().Failed(Arg.Any <Exception>());
        }
Ejemplo n.º 18
0
        public void Given_Step_Crashed_Should_Rollback_Passed_Steps()
        {
            Workflow.Add <TestStep>();
            Workflow.Add <CrashingStep>();

            Workflow.Execute(Context);

            Context.Out.Received(1).Rollback(Arg.Any <TestStep>());
        }
Ejemplo n.º 19
0
        public void Should_Execute_Success_Handler_On_Success()
        {
            Workflow.Add <TestStep>();
            Workflow.OnSuccess(ctx => ctx.Out.Success());

            Workflow.Execute(Context);

            Context.Out.Received().Success();
        }
Ejemplo n.º 20
0
        public void Should_Not_Execute_Success_Handler_When_Steps_Crashed()
        {
            Workflow.Add <TestStep>();
            Workflow.Add <CrashingStep>();

            Workflow.Execute(Context);

            Context.Out.DidNotReceive().Success();
        }
Ejemplo n.º 21
0
        public void Given_Step_Fails_Should_Mark_It_As_Failed()
        {
            Workflow.Add <FailingStep>();

            Workflow.Execute(Context);

            Workflow.PassedSteps.Should().HaveCount(0);
            Workflow.FailedSteps.Should().HaveCount(1);
        }
Ejemplo n.º 22
0
        public void Given_Step_Thrown_Exception_Should_Fail_Step()
        {
            Workflow.Add <CrashingStep>();

            Workflow.Execute(Context);

            Workflow.PassedSteps.Should().HaveCount(0);
            Workflow.FailedSteps.Should().HaveCount(1);
        }
Ejemplo n.º 23
0
        public void Should_Stop_Workflow_Execution_When_Step_Crashes()
        {
            Workflow.Add <CrashingStep>();
            Workflow.Add <TestStep>();

            Workflow.Execute(Context);

            Context.Out.DidNotReceive().Executed(Arg.Any <TestStep>());
        }
Ejemplo n.º 24
0
        public void Should_Not_Execute_Step_If_Any_Of_Required_Skipped()
        {
            Workflow.Add <DependsOnSkippedStep>();
            Workflow.Add <SkipStep>();

            Workflow.Execute(Context);

            Output.DidNotReceive().Executed(Arg.Any <DependsOnSkippedStep>());
        }
Ejemplo n.º 25
0
        public void Given_Step_Calls_Fail_Twice_Should_Be_Added_To_Failed_Only_Once()
        {
            Workflow.Add <FailingTwiceStep>();

            Workflow.Execute(Context);

            Workflow.FailedSteps.Should().HaveCount(1);
            Context.Out.Received(1).Executed(Arg.Any <FailingTwiceStep>());
        }
Ejemplo n.º 26
0
        public void Given_Test_Calls_Skip_Should_Be_Skiped()
        {
            Workflow.Add <SkipStep>();

            Workflow.Execute(Context);

            Workflow.FailedSteps.Should().HaveCount(0);
            Workflow.PassedSteps.Should().HaveCount(0);
            Workflow.SkippedSteps.Should().HaveCount(1);
        }
Ejemplo n.º 27
0
        public void Workflow_Add_adds_IExecutable_to_taskList()
        {
            var work = new Workflow();
            var task = new SplineReticulator("curvilinear");

            work.Add(task);
            var result = work.GetTaskList();

            result.Should().Contain(task);
        }
Ejemplo n.º 28
0
        public void Should_Execute_Step_When_Any_Of_Required_Executed_Case2()
        {
            Workflow.Add <MultiDependentStep>();
            Workflow.Add <AnotherRequiredStep>();

            Workflow.Execute(Context);

            Output.Received().Executed(Arg.Any <AnotherRequiredStep>());
            Output.Received().Executed(Arg.Any <MultiDependentStep>());
        }
Ejemplo n.º 29
0
        public void Should_Not_Execute_Success_Handler_When_Steps_Failed()
        {
            Workflow.Add <TestStep>();
            Workflow.Add <FailingStep>();
            Workflow.OnSuccess(ctx => ctx.Out.Success());

            Workflow.Execute(Context);

            Context.Out.DidNotReceive().Success();
        }
Ejemplo n.º 30
0
        private void button1_Click(object sender, EventArgs e)
        {
            Workflow sub = new Workflow("sub");

            sub.Add(new CallNode("call sub.1"));
            sub.Add(new CallNode("call sub.2"));
            sub.Add(new CallNode("call sub.3"));
            sub.Add(new CallNode("call sub.4"));
            sub.Add(new CallNode("call sub.5"));
            sub.Add(new CallNode("call sub.6"));

            Workflow workflow = new Workflow("main");
            Compiler compiler = new Compiler();

            workflow.Add(new CallNode("call 1"));
            workflow.Add(new CallNode("call 2"));
            workflow.Add(new LoopNode("x = 0", "x++", "x < 10", new CallNode("call 3.1"), new CallNode("call 3.2")));

            var fork = new ForkNode();

            fork.AddBranch(new CallNode("call 4.1.1"), new CallNode("call 4.1.2"), new CallNode("call 4.1.3"));
            fork.AddBranch(new CallNode("call 4.2"));
            fork.AddBranch(new CallNode("call 4.3"));
            workflow.Add(fork);

            var ifnode = new IfNode();

            ifnode.AddBranch("y < 1", new CallNode("call 5.1.1"), new CallNode("call 5.1.2"), new CallNode("call 5.1.3"));
            ifnode.AddBranch("y > 1", new CallNode("call 5.2"));
            ifnode.AddBranch("else", new CallNode("call 5.3"));
            workflow.Add(ifnode);

            workflow.Add(new CallNode("call 6"));
            workflow.Add(new SubCallNode(sub));
            workflow.Add(new CallNode("call 7"));

            IList <Instruction> instructions = compiler.Compile(workflow);

            int i = 0;

            foreach (var instruction in instructions)
            {
                LogManager.GetLogger("SCRIPT").InfoFormat("{0}:  {1}({2})",
                                                          i++, instruction.OpCode, instruction.Argument);
            }
            LogManager.GetLogger("SCRIPT").Info("====================================================");

            Executor executor = new Executor(instructions);

            executor.Debugger = new TestDebugger();
            executor.Run();
        }
Ejemplo n.º 31
0
        public void Should_Execute_If_Non_Required_Step_Failed()
        {
            Workflow.Add <DependentStep>();
            Workflow.Add <CrashingStep>();
            Workflow.Add <RequiredStep>();

            Workflow.Execute(Context);

            Output.Received().Executed(Arg.Any <RequiredStep>());
            Output.Received().Executed(Arg.Any <DependentStep>());
        }