-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProcessUnitTest.cs
82 lines (68 loc) · 2.12 KB
/
ProcessUnitTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using Camunda.Api.Client;
using Camunda.Api.Client.ExternalTask;
using Camunda.Api.Client.Message;
using Camunda.Api.Client.ProcessInstance;
using Camunda.Test.Example.ProcessEngine;
using NUnit.Framework;
namespace Camunda.Test.Example
{
[TestFixture]
public class ProcessUnitTest
{
private ProcessEngineTestHelper testHelper;
private DockerProcessEngine dockerProcessEngine;
/* Initiliazing the Camunda Client and deploying bpmns*/
[OneTimeSetUp]
public void globalInitialize()
{
dockerProcessEngine = new DockerProcessEngine();
dockerProcessEngine.Start();
}
[SetUp]
public void initialize()
{
testHelper = new ProcessEngineTestHelper();
testHelper.DeployModel("payment-process.bpmn");
}
[TearDown]
public void cleanup()
{
testHelper.CleanModels();
}
[OneTimeTearDown]
public void globalCleanup()
{
dockerProcessEngine.Stop();
}
[Test]
public void TestHappyPath()
{
/* Creating the message and sending it to Camunda */
var message = new CorrelationMessage()
{
MessageName = "MessagePaymentRequested",
BusinessKey = Guid.NewGuid().ToString()
};
message.ProcessVariables
.Set("paymentAmount", 10000)
.Set("error", false)
.Set("fail", false)
.Set("resolvable", true);
testHelper.CorrelateMessage(message);
List<LockedExternalTask> chargeCreditTasks = testHelper.FetchAndLockTasks("charge-credit");
Assert.AreEqual(chargeCreditTasks.Count, 1);
Dictionary<string, VariableValue> variables = new Dictionary<string, VariableValue>();
variables.Set("remainingAmount", 0);
testHelper.RunExternalTasks(chargeCreditTasks, variables);
List<LockedExternalTask> paymentFinishedTasks = testHelper.FetchAndLockTasks("payment-finished");
testHelper.RunExternalTasks(paymentFinishedTasks, null);
List<ProcessInstanceInfo> runningInstances = testHelper.QueryProcessInstances(new ProcessInstanceQuery()
{
ProcessDefinitionKey = "PaymentProcess"
});
Assert.AreEqual(runningInstances.Count, 0);
}
}
}