Exemple #1
0
        public void TestWorkflowProgressLoopingSimple()
        {
            //IWorkContext context = new WorkContext(null, TestEnvironment.Client);
            // defines and executes a cyclic (looping) workflow
            var w = new LoopingStep();

            w.Initialise(_workContext);
            var inp = new LoopInput {
                begin = 0, end = 2000
            };

            // loops until condition is true
            // start and monitor
            _workContext.Logger.LogDebug("Starting...");
            _workContext.Logger.LogDebug("[{0}] {1}", "I", w.Progress);
            //LoopResult result = w.Execute(inp, TimeSpan.FromSeconds(10));
            AsyncResult <WorkflowOutput <LoopResult> > ar = w.BeginExecute(inp, null);
            int loop = 0;

            while (!ar.IsCompleted)
            {
                Thread.Sleep(1000);
                _workContext.Logger.LogDebug("[{0}] {1}", loop, w.Progress);
                loop++;
            }
            LoopResult result = ar.EndInvoke().Result;

            _workContext.Logger.LogDebug("[{0}] {1}", "Z", w.Progress);
            Assert.AreEqual(2001000, result.total);
            _workContext.Logger.LogDebug("Complete.");
        }
Exemple #2
0
        public void TestWorkstepLoopingOverride()
        {
            // defines and executes a cyclic (looping) workflow
            var w = new LoopingStep();

            w.Initialise(_workContext);
            var inp = new LoopInput {
                begin = 0, end = 2000
            };
            // loops until condition is true
            LoopResult result = w.Execute(inp).Result;

            Assert.AreEqual(2001000, result.total);
        }