1
1
using System ;
2
2
using System . Collections . Generic ;
3
- using System . Text ;
3
+ using System . Linq ;
4
+ using System . Threading . Tasks ;
5
+ using FluentAssertions ;
4
6
using WorkflowCore . Interface ;
5
7
using WorkflowCore . Models ;
6
- using Xunit ;
7
- using FluentAssertions ;
8
8
using WorkflowCore . TestAssets ;
9
- using System . Threading . Tasks ;
9
+ using Xunit ;
10
10
11
11
namespace WorkflowCore . UnitTests
12
12
{
@@ -50,7 +50,7 @@ public void GetWorkflowInstance_should_retrieve_workflow()
50
50
NextExecution = 0 ,
51
51
Version = 1 ,
52
52
WorkflowDefinitionId = "My Workflow" ,
53
- Reference = "My Reference"
53
+ Reference = "My Reference"
54
54
} ;
55
55
workflow . ExecutionPointers . Add ( new ExecutionPointer ( )
56
56
{
@@ -69,6 +69,89 @@ public void GetWorkflowInstance_should_retrieve_workflow()
69
69
. Scope . Should ( ) . ContainInOrder ( workflow . ExecutionPointers . FindById ( "1" ) . Scope ) ;
70
70
}
71
71
72
+ [ Fact ]
73
+ public void GetWorkflowInstances_should_retrieve_workflows ( )
74
+ {
75
+ var workflow01 = new WorkflowInstance ( )
76
+ {
77
+ Data = new TestData ( ) { Value1 = 7 } ,
78
+ Description = "My Description" ,
79
+ Status = WorkflowStatus . Runnable ,
80
+ NextExecution = 0 ,
81
+ Version = 1 ,
82
+ WorkflowDefinitionId = "My Workflow" ,
83
+ Reference = "My Reference"
84
+ } ;
85
+ workflow01 . ExecutionPointers . Add ( new ExecutionPointer ( )
86
+ {
87
+ Id = "1" ,
88
+ Active = true ,
89
+ StepId = 0 ,
90
+ SleepUntil = new DateTime ( 2000 , 1 , 1 ) . ToUniversalTime ( ) ,
91
+ Scope = new List < string > ( ) { "4" , "3" , "2" , "1" }
92
+ } ) ;
93
+ var workflowId01 = Subject . CreateNewWorkflow ( workflow01 ) . Result ;
94
+
95
+ var workflow02 = new WorkflowInstance ( )
96
+ {
97
+ Data = new TestData ( ) { Value1 = 7 } ,
98
+ Description = "My Description" ,
99
+ Status = WorkflowStatus . Runnable ,
100
+ NextExecution = 0 ,
101
+ Version = 1 ,
102
+ WorkflowDefinitionId = "My Workflow" ,
103
+ Reference = "My Reference"
104
+ } ;
105
+ workflow02 . ExecutionPointers . Add ( new ExecutionPointer ( )
106
+ {
107
+ Id = "1" ,
108
+ Active = true ,
109
+ StepId = 0 ,
110
+ SleepUntil = new DateTime ( 2000 , 1 , 1 ) . ToUniversalTime ( ) ,
111
+ Scope = new List < string > ( ) { "4" , "3" , "2" , "1" }
112
+ } ) ;
113
+ var workflowId02 = Subject . CreateNewWorkflow ( workflow01 ) . Result ;
114
+
115
+ var workflow03 = new WorkflowInstance ( )
116
+ {
117
+ Data = new TestData ( ) { Value1 = 7 } ,
118
+ Description = "My Description" ,
119
+ Status = WorkflowStatus . Runnable ,
120
+ NextExecution = 0 ,
121
+ Version = 1 ,
122
+ WorkflowDefinitionId = "My Workflow" ,
123
+ Reference = "My Reference"
124
+ } ;
125
+ workflow03 . ExecutionPointers . Add ( new ExecutionPointer ( )
126
+ {
127
+ Id = "1" ,
128
+ Active = true ,
129
+ StepId = 0 ,
130
+ SleepUntil = new DateTime ( 2000 , 1 , 1 ) . ToUniversalTime ( ) ,
131
+ Scope = new List < string > ( ) { "4" , "3" , "2" , "1" }
132
+ } ) ;
133
+ var workflowId03 = Subject . CreateNewWorkflow ( workflow01 ) . Result ;
134
+
135
+ var retrievedWorkflows = Subject . GetWorkflowInstances ( new [ ] { workflowId01 , workflowId02 , workflowId03 } ) . Result ;
136
+
137
+ retrievedWorkflows . Count ( ) . ShouldBeEquivalentTo ( 3 ) ;
138
+
139
+ var retrievedWorkflow01 = retrievedWorkflows . Single ( o => o . Id == workflowId01 ) ;
140
+ retrievedWorkflow01 . ShouldBeEquivalentTo ( workflow01 ) ;
141
+ retrievedWorkflow01 . ExecutionPointers . FindById ( "1" )
142
+ . Scope . Should ( ) . ContainInOrder ( workflow01 . ExecutionPointers . FindById ( "1" ) . Scope ) ;
143
+
144
+ var retrievedWorkflow02 = retrievedWorkflows . Single ( o => o . Id == workflowId02 ) ;
145
+ retrievedWorkflow02 . ShouldBeEquivalentTo ( workflow02 ) ;
146
+ retrievedWorkflow02 . ExecutionPointers . FindById ( "1" )
147
+ . Scope . Should ( ) . ContainInOrder ( workflow02 . ExecutionPointers . FindById ( "1" ) . Scope ) ;
148
+
149
+ var retrievedWorkflow03 = retrievedWorkflows . Single ( o => o . Id == workflowId03 ) ;
150
+ retrievedWorkflow03 . ShouldBeEquivalentTo ( workflow03 ) ;
151
+ retrievedWorkflow03 . ExecutionPointers . FindById ( "1" )
152
+ . Scope . Should ( ) . ContainInOrder ( workflow03 . ExecutionPointers . FindById ( "1" ) . Scope ) ;
153
+ }
154
+
72
155
[ Fact ]
73
156
public void PersistWorkflow ( )
74
157
{
@@ -150,4 +233,4 @@ public class TestData
150
233
{
151
234
public int Value1 { get ; set ; }
152
235
}
153
- }
236
+ }
0 commit comments