@@ -36,7 +36,7 @@ protected override TestSubscriber.Probe<int> Setup(IPublisher<int> p1, IPublishe
36
36
}
37
37
38
38
[ Fact ]
39
- public void A_Concat_for_Flow_must_be_able_to_concat_Flow_with_Source ( )
39
+ public async Task A_Concat_for_Flow_must_be_able_to_concat_Flow_with_Source ( )
40
40
{
41
41
var f1 = Flow . Create < int > ( ) . Select ( x => x + "-s" ) ;
42
42
var s1 = Source . From ( new [ ] { 1 , 2 , 3 } ) ;
@@ -48,14 +48,17 @@ public void A_Concat_for_Flow_must_be_able_to_concat_Flow_with_Source()
48
48
var res = f1 . Concat ( s2 ) . RunWith ( s1 , subSink , Materializer ) . Item2 ;
49
49
50
50
res . Subscribe ( subs ) ;
51
- var sub = subs . ExpectSubscription ( ) ;
51
+ var sub = await subs . ExpectSubscriptionAsync ( ) ;
52
52
sub . Request ( 9 ) ;
53
- Enumerable . Range ( 1 , 6 ) . ForEach ( e=> subs . ExpectNext ( e + "-s" ) ) ;
54
- subs . ExpectComplete ( ) ;
53
+
54
+ foreach ( var e in Enumerable . Range ( 1 , 6 ) )
55
+ await subs . ExpectNextAsync ( e + "-s" ) ;
56
+
57
+ await subs . ExpectCompleteAsync ( ) ;
55
58
}
56
59
57
60
[ Fact ]
58
- public void A_Concat_for_Flow_must_be_able_to_prepend_a_Source_to_a_Flow ( )
61
+ public async Task A_Concat_for_Flow_must_be_able_to_prepend_a_Source_to_a_Flow ( )
59
62
{
60
63
var s1 = Source . From ( new [ ] { 1 , 2 , 3 } ) . Select ( x => x + "-s" ) ;
61
64
var s2 = Source . From ( new [ ] { 4 , 5 , 6 } ) ;
@@ -67,48 +70,56 @@ public void A_Concat_for_Flow_must_be_able_to_prepend_a_Source_to_a_Flow()
67
70
var res = f2 . Prepend ( s1 ) . RunWith ( s2 , subSink , Materializer ) . Item2 ;
68
71
69
72
res . Subscribe ( subs ) ;
70
- var sub = subs . ExpectSubscription ( ) ;
73
+ var sub = await subs . ExpectSubscriptionAsync ( ) ;
71
74
sub . Request ( 9 ) ;
72
- Enumerable . Range ( 1 , 6 ) . ForEach ( e => subs . ExpectNext ( e + "-s" ) ) ;
73
- subs . ExpectComplete ( ) ;
75
+
76
+ foreach ( var e in Enumerable . Range ( 1 , 6 ) )
77
+ await subs . ExpectNextAsync ( e + "-s" ) ;
78
+
79
+ await subs . ExpectCompleteAsync ( ) ;
74
80
}
75
81
76
82
[ Fact ]
77
- public void A_Concat_for_Flow_must_work_with_one_immediately_completed_and_one_nonempty_publisher ( )
83
+ public async Task A_Concat_for_Flow_must_work_with_one_immediately_completed_and_one_nonempty_publisher ( )
78
84
{
79
- this . AssertAllStagesStopped ( ( ) =>
80
- {
85
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
81
86
var subscriber1 = Setup ( CompletedPublisher < int > ( ) , NonEmptyPublisher ( Enumerable . Range ( 1 , 4 ) ) ) ;
82
- var subscription1 = subscriber1 . ExpectSubscription ( ) ;
87
+ var subscription1 = await subscriber1 . ExpectSubscriptionAsync ( ) ;
83
88
subscription1 . Request ( 5 ) ;
84
- Enumerable . Range ( 1 , 4 ) . ForEach ( x => subscriber1 . ExpectNext ( x ) ) ;
85
- subscriber1 . ExpectComplete ( ) ;
89
+
90
+ foreach ( var x in Enumerable . Range ( 1 , 4 ) )
91
+ await subscriber1 . ExpectNextAsync ( x ) ;
92
+
93
+ await subscriber1 . ExpectCompleteAsync ( ) ;
86
94
87
95
var subscriber2 = Setup ( NonEmptyPublisher ( Enumerable . Range ( 1 , 4 ) ) , CompletedPublisher < int > ( ) ) ;
88
- var subscription2 = subscriber2 . ExpectSubscription ( ) ;
96
+ var subscription2 = await subscriber2 . ExpectSubscriptionAsync ( ) ;
89
97
subscription2 . Request ( 5 ) ;
90
- Enumerable . Range ( 1 , 4 ) . ForEach ( x => subscriber2 . ExpectNext ( x ) ) ;
91
- subscriber2 . ExpectComplete ( ) ;
98
+
99
+ foreach ( var x in Enumerable . Range ( 1 , 4 ) )
100
+ await subscriber2 . ExpectNextAsync ( x ) ;
101
+
102
+ await subscriber2 . ExpectCompleteAsync ( ) ;
103
+
92
104
} , Materializer ) ;
93
105
}
94
106
95
107
[ Fact ]
96
- public void A_Concat_for_Flow_must_work_with_one_immediately_failed_and_one_nonempty_publisher ( )
108
+ public async Task A_Concat_for_Flow_must_work_with_one_immediately_failed_and_one_nonempty_publisher ( )
97
109
{
98
- this . AssertAllStagesStopped ( ( ) =>
99
- {
110
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
100
111
var subscriber = Setup ( FailedPublisher < int > ( ) , NonEmptyPublisher ( Enumerable . Range ( 1 , 4 ) ) ) ;
101
112
subscriber . ExpectSubscriptionAndError ( ) . Should ( ) . BeOfType < TestException > ( ) ;
113
+ return Task . CompletedTask ;
102
114
} , Materializer ) ;
103
115
}
104
116
105
117
[ Fact ]
106
- public void A_Concat_for_Flow_must_work_with_one_nonempty_and_one_immediately_failed_publisher ( )
118
+ public async Task A_Concat_for_Flow_must_work_with_one_nonempty_and_one_immediately_failed_publisher ( )
107
119
{
108
- this . AssertAllStagesStopped ( ( ) =>
109
- {
120
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
110
121
var subscriber = Setup ( NonEmptyPublisher ( Enumerable . Range ( 1 , 4 ) ) , FailedPublisher < int > ( ) ) ;
111
- subscriber . ExpectSubscription ( ) . Request ( 5 ) ;
122
+ ( await subscriber . ExpectSubscriptionAsync ( ) ) . Request ( 5 ) ;
112
123
113
124
var errorSignalled = Enumerable . Range ( 1 , 4 )
114
125
. Aggregate ( false , ( b , e ) => b || subscriber . ExpectNextOrError ( ) is TestException ) ;
@@ -118,22 +129,21 @@ public void A_Concat_for_Flow_must_work_with_one_nonempty_and_one_immediately_fa
118
129
}
119
130
120
131
[ Fact ]
121
- public void A_Concat_for_Flow_must_work_with_one_delayed_failed_and_one_nonempty_publisher ( )
132
+ public async Task A_Concat_for_Flow_must_work_with_one_delayed_failed_and_one_nonempty_publisher ( )
122
133
{
123
- this . AssertAllStagesStopped ( ( ) =>
124
- {
134
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
125
135
var subscriber = Setup ( SoonToFailPublisher < int > ( ) , NonEmptyPublisher ( Enumerable . Range ( 1 , 4 ) ) ) ;
126
136
subscriber . ExpectSubscriptionAndError ( ) . Should ( ) . BeOfType < TestException > ( ) ;
137
+ return Task . CompletedTask ;
127
138
} , Materializer ) ;
128
139
}
129
140
130
141
[ Fact ]
131
- public void A_Concat_for_Flow_must_work_with_one_nonempty_and_one_delayed_failed_publisher ( )
142
+ public async Task A_Concat_for_Flow_must_work_with_one_nonempty_and_one_delayed_failed_publisher ( )
132
143
{
133
- this . AssertAllStagesStopped ( ( ) =>
134
- {
144
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
135
145
var subscriber = Setup ( NonEmptyPublisher ( Enumerable . Range ( 1 , 4 ) ) , SoonToFailPublisher < int > ( ) ) ;
136
- subscriber . ExpectSubscription ( ) . Request ( 5 ) ;
146
+ ( await subscriber . ExpectSubscriptionAsync ( ) ) . Request ( 5 ) ;
137
147
138
148
var errorSignalled = Enumerable . Range ( 1 , 4 )
139
149
. Aggregate ( false , ( b , e ) => b || subscriber . ExpectNextOrError ( ) is TestException ) ;
@@ -143,54 +153,56 @@ public void A_Concat_for_Flow_must_work_with_one_nonempty_and_one_delayed_failed
143
153
}
144
154
145
155
[ Fact ]
146
- public void A_Concat_for_Flow_must_correctly_handle_async_errors_in_secondary_upstream ( )
156
+ public async Task A_Concat_for_Flow_must_correctly_handle_async_errors_in_secondary_upstream ( )
147
157
{
148
- this . AssertAllStagesStopped ( ( ) =>
149
- {
158
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
150
159
var promise = new TaskCompletionSource < int > ( ) ;
151
160
var subscriber = this . CreateManualSubscriberProbe < int > ( ) ;
152
161
Source . From ( Enumerable . Range ( 1 , 3 ) )
153
162
. Concat ( Source . FromTask ( promise . Task ) )
154
163
. RunWith ( Sink . FromSubscriber ( subscriber ) , Materializer ) ;
155
164
156
- var subscription = subscriber . ExpectSubscription ( ) ;
165
+ var subscription = await subscriber . ExpectSubscriptionAsync ( ) ;
157
166
subscription . Request ( 4 ) ;
158
- Enumerable . Range ( 1 , 3 ) . ForEach ( x => subscriber . ExpectNext ( x ) ) ;
167
+
168
+ foreach ( var x in Enumerable . Range ( 1 , 3 ) )
169
+ await subscriber . ExpectNextAsync ( x ) ;
170
+
159
171
promise . SetException ( TestException ( ) ) ;
160
172
subscriber . ExpectError ( ) . Should ( ) . BeOfType < TestException > ( ) ;
173
+
161
174
} , Materializer ) ;
162
175
}
163
176
164
177
[ Fact ]
165
- public void A_Concat_for_Flow_must_work_with_Source_DSL ( )
178
+ public async Task A_Concat_for_Flow_must_work_with_Source_DSL ( )
166
179
{
167
- this . AssertAllStagesStopped ( ( ) =>
168
- {
169
- var testSource =
170
- Source . From ( Enumerable . Range ( 1 , 5 ) )
171
- . ConcatMaterialized ( Source . From ( Enumerable . Range ( 6 , 5 ) ) , Keep . Both )
172
- . Grouped ( 1000 ) ;
180
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
181
+ var testSource =
182
+ Source . From ( Enumerable . Range ( 1 , 5 ) )
183
+ . ConcatMaterialized ( Source . From ( Enumerable . Range ( 6 , 5 ) ) , Keep . Both )
184
+ . Grouped ( 1000 ) ;
173
185
var task = testSource . RunWith ( Sink . First < IEnumerable < int > > ( ) , Materializer ) ;
174
186
task . Wait ( TimeSpan . FromSeconds ( 3 ) ) . Should ( ) . BeTrue ( ) ;
175
- task . Result . Should ( ) . BeEquivalentTo ( Enumerable . Range ( 1 , 10 ) ) ;
187
+ task . Result . Should ( ) . BeEquivalentTo ( Enumerable . Range ( 1 , 10 ) ) ;
176
188
177
189
var runnable = testSource . ToMaterialized ( Sink . Ignore < IEnumerable < int > > ( ) , Keep . Left ) ;
178
190
var t = runnable . Run ( Materializer ) ;
179
191
t . Item1 . Should ( ) . BeOfType < NotUsed > ( ) ;
180
192
t . Item2 . Should ( ) . BeOfType < NotUsed > ( ) ;
181
193
182
194
runnable . MapMaterializedValue ( _ => "boo" ) . Run ( Materializer ) . Should ( ) . Be ( "boo" ) ;
195
+ return Task . CompletedTask ;
183
196
} , Materializer ) ;
184
197
}
185
198
186
199
[ Fact ]
187
- public void A_Concat_for_Flow_must_work_with_Flow_DSL ( )
200
+ public async Task A_Concat_for_Flow_must_work_with_Flow_DSL ( )
188
201
{
189
- this . AssertAllStagesStopped ( ( ) =>
190
- {
191
- var testFlow = Flow . Create < int > ( )
192
- . ConcatMaterialized ( Source . From ( Enumerable . Range ( 6 , 5 ) ) , Keep . Both )
193
- . Grouped ( 1000 ) ;
202
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
203
+ var testFlow = Flow . Create < int > ( )
204
+ . ConcatMaterialized ( Source . From ( Enumerable . Range ( 6 , 5 ) ) , Keep . Both )
205
+ . Grouped ( 1000 ) ;
194
206
var task = Source . From ( Enumerable . Range ( 1 , 5 ) )
195
207
. ViaMaterialized ( testFlow , Keep . Both )
196
208
. RunWith ( Sink . First < IEnumerable < int > > ( ) , Materializer ) ;
@@ -204,65 +216,52 @@ public void A_Concat_for_Flow_must_work_with_Flow_DSL()
204
216
runnable . Invoking ( r => r . Run ( Materializer ) ) . Should ( ) . NotThrow ( ) ;
205
217
206
218
runnable . MapMaterializedValue ( _ => "boo" ) . Run ( Materializer ) . Should ( ) . Be ( "boo" ) ;
219
+ return Task . CompletedTask ;
207
220
} , Materializer ) ;
208
221
}
209
222
210
223
[ Fact ( Skip = "ConcatMaterialized type conflict" ) ]
211
- public void A_Concat_for_Flow_must_work_with_Flow_DSL2 ( )
224
+ public async Task A_Concat_for_Flow_must_work_with_Flow_DSL2 ( )
212
225
{
213
- this . AssertAllStagesStopped ( ( ) =>
214
- {
215
- var testFlow = Flow . Create < int > ( )
216
- . ConcatMaterialized ( Source . From ( Enumerable . Range ( 6 , 5 ) ) , Keep . Both )
217
- . Grouped ( 1000 ) ;
226
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
227
+ var testFlow = Flow . Create < int > ( )
228
+ . ConcatMaterialized ( Source . From ( Enumerable . Range ( 6 , 5 ) ) , Keep . Both )
229
+ . Grouped ( 1000 ) ;
218
230
var task = Source . From ( Enumerable . Range ( 1 , 5 ) )
219
231
. ViaMaterialized ( testFlow , Keep . Both )
220
232
. RunWith ( Sink . First < IEnumerable < int > > ( ) , Materializer ) ;
221
233
task . Wait ( TimeSpan . FromSeconds ( 3 ) ) . Should ( ) . BeTrue ( ) ;
222
234
task . Result . Should ( ) . BeEquivalentTo ( Enumerable . Range ( 1 , 10 ) ) ;
223
-
224
- //var sink = testFlow.ConcatMaterialized(Source.From(Enumerable.Range(1, 5)), Keep.Both)
225
- // .To(Sink.Ignore<IEnumerable<int>>())
226
- // .MapMaterializedValue(
227
- // x =>
228
- // {
229
- // x.Item1.Item1.Should().BeOfType<NotUsed>();
230
- // x.Item1.Item2.Should().BeOfType<NotUsed>();
231
- // x.Item2.Should().BeOfType<NotUsed>();
232
- // return "boo";
233
- // });
234
-
235
- //Source.From(Enumerable.Range(10, 6)).RunWith(sink, Materializer).Should().Be("boo");
235
+ return Task . CompletedTask ;
236
236
} , Materializer ) ;
237
237
}
238
238
239
239
[ Fact ]
240
- public void A_Concat_for_Flow_must_subscribe_at_one_to_initial_source_and_to_one_that_it_is_concat_to ( )
240
+ public async Task A_Concat_for_Flow_must_subscribe_at_one_to_initial_source_and_to_one_that_it_is_concat_to ( )
241
241
{
242
- this . AssertAllStagesStopped ( ( ) =>
243
- {
242
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
244
243
var publisher1 = this . CreatePublisherProbe < int > ( ) ;
245
244
var publisher2 = this . CreatePublisherProbe < int > ( ) ;
246
245
var probeSink =
247
246
Source . FromPublisher ( publisher1 )
248
247
. Concat ( Source . FromPublisher ( publisher2 ) )
249
248
. RunWith ( this . SinkProbe < int > ( ) , Materializer ) ;
250
249
251
- var sub1 = publisher1 . ExpectSubscription ( ) ;
252
- var sub2 = publisher2 . ExpectSubscription ( ) ;
253
- var subSink = probeSink . ExpectSubscription ( ) ;
250
+ var sub1 = await publisher1 . ExpectSubscriptionAsync ( ) ;
251
+ var sub2 = await publisher2 . ExpectSubscriptionAsync ( ) ;
252
+ var subSink = await probeSink . ExpectSubscriptionAsync ( ) ;
254
253
255
254
sub1 . SendNext ( 1 ) ;
256
255
subSink . Request ( 1 ) ;
257
- probeSink . ExpectNext ( 1 ) ;
256
+ await probeSink . ExpectNextAsync ( 1 ) ;
258
257
sub1 . SendComplete ( ) ;
259
258
260
259
sub2 . SendNext ( 2 ) ;
261
260
subSink . Request ( 1 ) ;
262
- probeSink . ExpectNext ( 2 ) ;
261
+ await probeSink . ExpectNextAsync ( 2 ) ;
263
262
sub2 . SendComplete ( ) ;
264
263
265
- probeSink . ExpectComplete ( ) ;
264
+ await probeSink . ExpectCompleteAsync ( ) ;
266
265
} , Materializer ) ;
267
266
}
268
267
}
0 commit comments