Exemple #1
0
        public async Task Exclusive()
        {
            var xaml = File.ReadAllText("..\\..\\..\\TestFiles\\exclusive_gateway.bpmn");

            var sp = TestEngine.ServiceProvider();

            var wfs = sp.GetService <IWorkflowStorage>();
            var wfc = sp.GetService <IWorkflowCatalog>();

            String wfId = "Exclusive_1";
            await wfc.SaveAsync(new WorkflowDescriptor()
            {
                Id     = wfId,
                Body   = xaml,
                Format = "xaml"
            });

            var ident = await wfs.PublishAsync(wfc, wfId);

            var wfe  = sp.GetService <IWorkflowEngine>();
            var inst = await wfe.CreateAsync(ident);

            inst = await wfe.RunAsync(inst.Id, new { X = 6 });

            var res = inst.Result;

            Assert.AreEqual("Yes", res.Get <String>("R"));

            inst = await wfe.CreateAsync(ident);

            inst = await wfe.RunAsync(inst.Id, new { X = 4 });

            res = inst.Result;
            Assert.AreEqual("No", res.Get <String>("R"));
        }
Exemple #2
0
        public async Task UserTask()
        {
            var xaml = File.ReadAllText("..\\..\\..\\TestFiles\\user_task_1.bpmn");

            var sp = TestEngine.ServiceProvider();

            var wfs = sp.GetService <IWorkflowStorage>();
            var wfc = sp.GetService <IWorkflowCatalog>();

            String wfId = "Wait1";
            await wfc.SaveAsync(new WorkflowDescriptor()
            {
                Id     = wfId,
                Body   = xaml,
                Format = "xaml"
            });

            var ident = await wfs.PublishAsync(wfc, wfId);

            var wfe  = sp.GetService <IWorkflowEngine>();
            var inst = await wfe.CreateAsync(ident);

            inst = await wfe.RunAsync(inst.Id, new { X = 5 });

            var res = inst.Result;

            Assert.AreEqual(10, res.Get <Int32>("X"));

            inst = await wfe.ResumeAsync(inst.Id, "Activity_1rffhs5", new { V = 5 });

            res = inst.Result;
            Assert.AreEqual(15, res.Get <Int32>("X"));
        }
Exemple #3
0
        public async Task Parallel()
        {
            var xaml = File.ReadAllText("..\\..\\..\\TestFiles\\parallel_1.bpmn");

            var sp = TestEngine.ServiceProvider();

            var wfs = sp.GetService <IWorkflowStorage>();
            var wfc = sp.GetService <IWorkflowCatalog>();

            String wfId = "Parallel1";
            await wfc.SaveAsync(new WorkflowDescriptor()
            {
                Id     = wfId,
                Body   = xaml,
                Format = "xaml"
            });

            var ident = await wfs.PublishAsync(wfc, wfId);

            var wfe  = sp.GetService <IWorkflowEngine>();
            var inst = await wfe.CreateAsync(ident);

            inst = await wfe.RunAsync(inst, new { X = 5 });

            var res = inst.Result;

            Assert.AreEqual(12, res.Get <Int32>("X"));
        }
Exemple #4
0
        public async Task BoundaryTimer()
        {
            var xaml = File.ReadAllText("..\\..\\..\\TestFiles\\boundary_simple.bpmn");

            var sp = TestEngine.ServiceProvider();

            var wfs = sp.GetService <IWorkflowStorage>();
            var wfc = sp.GetService <IWorkflowCatalog>();

            String wfId = "BoundarySimple";
            await wfc.SaveAsync(new WorkflowDescriptor()
            {
                Id     = wfId,
                Body   = xaml,
                Format = "xaml"
            });

            var ident = await wfs.PublishAsync(wfc, wfId);

            var wfe  = sp.GetService <IWorkflowEngine>();
            var inst = await wfe.CreateAsync(ident);

            inst = await wfe.RunAsync(inst);

            var res0 = inst.Result;

            Assert.IsNull(res0.Get <String>("Result"));
            Assert.AreEqual(WorkflowExecutionStatus.Idle, inst.ExecutionStatus);

            var instTimer = await wfe.HandleEventAsync(inst.Id, "Event1");

            var res1 = instTimer.Result;

            Assert.AreEqual("Timer", res1.Get <String>("Result"));
            Assert.AreEqual(WorkflowExecutionStatus.Idle, instTimer.ExecutionStatus);

            var instResume = await wfe.ResumeAsync(inst.Id, "UserTask1");

            var res2 = instResume.Result;

            Assert.AreEqual("Normal", res2.Get <String>("Result"));
            Assert.AreEqual(WorkflowExecutionStatus.Complete, instResume.ExecutionStatus);
        }
Exemple #5
0
        public async Task IntermediateTimer()
        {
            var xaml = File.ReadAllText("..\\..\\..\\TestFiles\\intermediate_timer.bpmn");

            var sp = TestEngine.ServiceProvider();

            var wfs = sp.GetService <IWorkflowStorage>();
            var wfc = sp.GetService <IWorkflowCatalog>();
            var ins = sp.GetService <IInstanceStorage>();

            String wfId = "BoundarySimple";
            await wfc.SaveAsync(new WorkflowDescriptor()
            {
                Id     = wfId,
                Body   = xaml,
                Format = "xaml"
            });

            var ident = await wfs.PublishAsync(wfc, wfId);

            var wfe  = sp.GetService <IWorkflowEngine>();
            var inst = await wfe.CreateAsync(ident);

            inst = await wfe.RunAsync(inst);

            var res0 = inst.Result;

            Assert.AreEqual("Start", res0.Get <String>("Result"));
            Assert.AreEqual(WorkflowExecutionStatus.Idle, inst.ExecutionStatus);

            await wfe.ProcessPending();

            var instAfter = await ins.Load(inst.Id);

            var res1 = instAfter.Result;

            Assert.AreEqual("AfterTimer", res1.Get <String>("Result"));
            Assert.AreEqual(WorkflowExecutionStatus.Complete, instAfter.ExecutionStatus);
        }