@@ -31,13 +31,12 @@ public GraphBroadcastSpec(ITestOutputHelper helper) : base(helper)
31
31
}
32
32
33
33
[ Fact ]
34
- public void A_Broadcast_must_broadcast_to_other_subscriber ( )
34
+ public async Task A_Broadcast_must_broadcast_to_other_subscriber ( )
35
35
{
36
- this . AssertAllStagesStopped ( ( ) =>
37
- {
36
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
38
37
var c1 = this . CreateManualSubscriberProbe < int > ( ) ;
39
38
var c2 = this . CreateManualSubscriberProbe < int > ( ) ;
40
- RunnableGraph . FromGraph ( GraphDsl . Create ( b =>
39
+ RunnableGraph . FromGraph ( GraphDsl . Create ( b =>
41
40
{
42
41
var broadcast = b . Add ( new Broadcast < int > ( 2 ) ) ;
43
42
var source = Source . From ( Enumerable . Range ( 1 , 3 ) ) ;
@@ -51,50 +50,49 @@ public void A_Broadcast_must_broadcast_to_other_subscriber()
51
50
return ClosedShape . Instance ;
52
51
} ) ) . Run ( Materializer ) ;
53
52
54
- var sub1 = c1 . ExpectSubscription ( ) ;
55
- var sub2 = c2 . ExpectSubscription ( ) ;
53
+ var sub1 = await c1 . ExpectSubscriptionAsync ( ) ;
54
+ var sub2 = await c2 . ExpectSubscriptionAsync ( ) ;
56
55
57
56
sub1 . Request ( 1 ) ;
58
57
sub2 . Request ( 2 ) ;
59
58
60
- c1 . ExpectNext ( 1 ) . ExpectNoMsg ( TimeSpan . FromMilliseconds ( 100 ) ) ;
61
- c2 . ExpectNext ( 1 , 2 ) . ExpectNoMsg ( TimeSpan . FromMilliseconds ( 100 ) ) ;
59
+ await c1 . ExpectNext ( 1 ) . ExpectNoMsgAsync ( TimeSpan . FromMilliseconds ( 100 ) ) ;
60
+ await c2 . ExpectNext ( 1 , 2 ) . ExpectNoMsgAsync ( TimeSpan . FromMilliseconds ( 100 ) ) ;
62
61
sub1 . Request ( 3 ) ;
63
- c1 . ExpectNext ( 2 , 3 ) . ExpectComplete ( ) ;
62
+ await c1 . ExpectNext ( 2 , 3 ) . ExpectCompleteAsync ( ) ;
64
63
sub2 . Request ( 3 ) ;
65
- c2 . ExpectNext ( 3 ) . ExpectComplete ( ) ;
64
+ await c2 . ExpectNext ( 3 ) . ExpectCompleteAsync ( ) ;
66
65
} , Materializer ) ;
67
66
}
68
67
69
68
[ Fact ]
70
- public void A_Broadcast_must_work_with_one_way_broadcast ( )
69
+ public async Task A_Broadcast_must_work_with_one_way_broadcast ( )
71
70
{
72
- this . AssertAllStagesStopped ( ( ) =>
73
- {
74
- var t = Source . FromGraph ( GraphDsl . Create ( b =>
75
- {
76
- var broadcast = b . Add ( new Broadcast < int > ( 1 ) ) ;
71
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
72
+ var t = Source . FromGraph ( GraphDsl . Create ( b =>
73
+ {
74
+ var broadcast = b . Add ( new Broadcast < int > ( 1 ) ) ;
77
75
var source = b . Add ( Source . From ( Enumerable . Range ( 1 , 3 ) ) ) ;
78
-
76
+
79
77
b . From ( source ) . To ( broadcast . In ) ;
80
-
81
- return new SourceShape < int > ( broadcast . Out ( 0 ) ) ;
82
- } ) ) . RunAggregate ( new List < int > ( ) , ( list , i ) =>
83
- {
84
- list . Add ( i ) ;
85
- return list ;
78
+
79
+ return new SourceShape < int > ( broadcast . Out ( 0 ) ) ;
80
+ } ) ) . RunAggregate ( new List < int > ( ) , ( list , i ) =>
81
+ {
82
+ list . Add ( i ) ;
83
+ return list ;
86
84
} , Materializer ) ;
87
85
88
86
t . Wait ( TimeSpan . FromSeconds ( 3 ) ) . Should ( ) . BeTrue ( ) ;
89
- t . Result . Should ( ) . BeEquivalentTo ( new [ ] { 1 , 2 , 3 } ) ;
87
+ t . Result . Should ( ) . BeEquivalentTo ( new [ ] { 1 , 2 , 3 } ) ;
88
+ return Task . CompletedTask ;
90
89
} , Materializer ) ;
91
90
}
92
91
93
92
[ Fact ]
94
- public void A_Broadcast_must_work_with_n_way_broadcast ( )
93
+ public async Task A_Broadcast_must_work_with_n_way_broadcast ( )
95
94
{
96
- this . AssertAllStagesStopped ( ( ) =>
97
- {
95
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
98
96
var headSink = Sink . First < IEnumerable < int > > ( ) ;
99
97
100
98
var t = RunnableGraph . FromGraph ( GraphDsl . Create ( headSink , headSink , headSink , headSink , headSink , ValueTuple . Create ,
@@ -116,14 +114,14 @@ public void A_Broadcast_must_work_with_n_way_broadcast()
116
114
task . Wait ( TimeSpan . FromSeconds ( 3 ) ) . Should ( ) . BeTrue ( ) ;
117
115
foreach ( var list in task . Result )
118
116
list . Should ( ) . BeEquivalentTo ( new [ ] { 1 , 2 , 3 } ) ;
117
+ return Task . CompletedTask ;
119
118
} , Materializer ) ;
120
119
}
121
120
122
121
[ Fact ( Skip = "We don't have enough overloads for GraphDsl.Create" ) ]
123
- public void A_Broadcast_must_with_22_way_broadcast ( )
122
+ public async Task A_Broadcast_must_with_22_way_broadcast ( )
124
123
{
125
- this . AssertAllStagesStopped ( ( ) =>
126
- {
124
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
127
125
//var headSink = Sink.First<IEnumerable<int>>();
128
126
129
127
//var t = RunnableGraph.FromGraph(GraphDsl.Create(headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, headSink, ValueTuple.Create,
@@ -162,15 +160,14 @@ public void A_Broadcast_must_with_22_way_broadcast()
162
160
//task.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
163
161
//foreach (var list in task.Result)
164
162
// list.Should().BeEquivalentTo(new[] { 1, 2, 3 });
165
-
163
+ return Task . CompletedTask ;
166
164
} , Materializer ) ;
167
165
}
168
166
169
167
[ Fact ]
170
- public void A_Broadcast_must_produce_to_other_even_though_downstream_cancels ( )
168
+ public async Task A_Broadcast_must_produce_to_other_even_though_downstream_cancels ( )
171
169
{
172
- this . AssertAllStagesStopped ( ( ) =>
173
- {
170
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
174
171
var c1 = this . CreateManualSubscriberProbe < int > ( ) ;
175
172
var c2 = this . CreateManualSubscriberProbe < int > ( ) ;
176
173
RunnableGraph . FromGraph ( GraphDsl . Create ( b =>
@@ -187,20 +184,19 @@ public void A_Broadcast_must_produce_to_other_even_though_downstream_cancels()
187
184
return ClosedShape . Instance ;
188
185
} ) ) . Run ( Materializer ) ;
189
186
190
- var sub1 = c1 . ExpectSubscription ( ) ;
187
+ var sub1 = await c1 . ExpectSubscriptionAsync ( ) ;
191
188
sub1 . Cancel ( ) ;
192
- var sub2 = c2 . ExpectSubscription ( ) ;
189
+ var sub2 = await c2 . ExpectSubscriptionAsync ( ) ;
193
190
sub2 . Request ( 3 ) ;
194
- c2 . ExpectNext ( 1 , 2 , 3 ) ;
195
- c2 . ExpectComplete ( ) ;
191
+ c2 . ExpectNext ( 1 , 2 , 3 ) ;
192
+ await c2 . ExpectCompleteAsync ( ) ;
196
193
} , Materializer ) ;
197
194
}
198
195
199
196
[ Fact ]
200
- public void A_Broadcast_must_produce_to_downstream_even_though_other_cancels ( )
197
+ public async Task A_Broadcast_must_produce_to_downstream_even_though_other_cancels ( )
201
198
{
202
- this . AssertAllStagesStopped ( ( ) =>
203
- {
199
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
204
200
var c1 = this . CreateManualSubscriberProbe < int > ( ) ;
205
201
var c2 = this . CreateManualSubscriberProbe < int > ( ) ;
206
202
RunnableGraph . FromGraph ( GraphDsl . Create ( b =>
@@ -217,20 +213,19 @@ public void A_Broadcast_must_produce_to_downstream_even_though_other_cancels()
217
213
return ClosedShape . Instance ;
218
214
} ) ) . Run ( Materializer ) ;
219
215
220
- var sub1 = c1 . ExpectSubscription ( ) ;
221
- var sub2 = c2 . ExpectSubscription ( ) ;
216
+ var sub1 = await c1 . ExpectSubscriptionAsync ( ) ;
217
+ var sub2 = await c2 . ExpectSubscriptionAsync ( ) ;
222
218
sub2 . Cancel ( ) ;
223
219
sub1 . Request ( 3 ) ;
224
- c1 . ExpectNext ( 1 , 2 , 3 ) ;
225
- c1 . ExpectComplete ( ) ;
220
+ c1 . ExpectNext ( 1 , 2 , 3 ) ;
221
+ await c1 . ExpectCompleteAsync ( ) ;
226
222
} , Materializer ) ;
227
223
}
228
224
229
225
[ Fact ]
230
- public void A_Broadcast_must_cancel_upstream_when_downstreams_cancel ( )
226
+ public async Task A_Broadcast_must_cancel_upstream_when_downstreams_cancel ( )
231
227
{
232
- this . AssertAllStagesStopped ( ( ) =>
233
- {
228
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
234
229
var p1 = this . CreateManualPublisherProbe < int > ( ) ;
235
230
var c1 = this . CreateManualSubscriberProbe < int > ( ) ;
236
231
var c2 = this . CreateManualSubscriberProbe < int > ( ) ;
@@ -248,30 +243,29 @@ public void A_Broadcast_must_cancel_upstream_when_downstreams_cancel()
248
243
return ClosedShape . Instance ;
249
244
} ) ) . Run ( Materializer ) ;
250
245
251
- var bSub = p1 . ExpectSubscription ( ) ;
252
- var sub1 = c1 . ExpectSubscription ( ) ;
253
- var sub2 = c2 . ExpectSubscription ( ) ;
246
+ var bSub = await p1 . ExpectSubscriptionAsync ( ) ;
247
+ var sub1 = await c1 . ExpectSubscriptionAsync ( ) ;
248
+ var sub2 = await c2 . ExpectSubscriptionAsync ( ) ;
254
249
255
250
sub1 . Request ( 3 ) ;
256
251
sub2 . Request ( 3 ) ;
257
- p1 . ExpectRequest ( bSub , 16 ) ;
252
+ await p1 . ExpectRequestAsync ( bSub , 16 ) ;
258
253
bSub . SendNext ( 1 ) ;
259
- c1 . ExpectNext ( 1 ) ;
260
- c2 . ExpectNext ( 1 ) ;
254
+ await c1 . ExpectNextAsync ( 1 ) ;
255
+ await c2 . ExpectNextAsync ( 1 ) ;
261
256
bSub . SendNext ( 2 ) ;
262
- c1 . ExpectNext ( 2 ) ;
263
- c2 . ExpectNext ( 2 ) ;
257
+ await c1 . ExpectNextAsync ( 2 ) ;
258
+ await c2 . ExpectNextAsync ( 2 ) ;
264
259
sub1 . Cancel ( ) ;
265
260
sub2 . Cancel ( ) ;
266
- bSub . ExpectCancellation ( ) ;
261
+ await bSub . ExpectCancellationAsync ( ) ;
267
262
} , Materializer ) ;
268
263
}
269
264
270
265
[ Fact ]
271
- public void A_Broadcast_must_pass_along_early_cancellation ( )
266
+ public async Task A_Broadcast_must_pass_along_early_cancellation ( )
272
267
{
273
- this . AssertAllStagesStopped ( ( ) =>
274
- {
268
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
275
269
var c1 = this . CreateManualSubscriberProbe < int > ( ) ;
276
270
var c2 = this . CreateManualSubscriberProbe < int > ( ) ;
277
271
@@ -287,22 +281,21 @@ public void A_Broadcast_must_pass_along_early_cancellation()
287
281
288
282
var up = this . CreateManualPublisherProbe < int > ( ) ;
289
283
290
- var downSub1 = c1 . ExpectSubscription ( ) ;
291
- var downSub2 = c2 . ExpectSubscription ( ) ;
284
+ var downSub1 = await c1 . ExpectSubscriptionAsync ( ) ;
285
+ var downSub2 = await c2 . ExpectSubscriptionAsync ( ) ;
292
286
downSub1 . Cancel ( ) ;
293
287
downSub2 . Cancel ( ) ;
294
288
295
289
up . Subscribe ( s ) ;
296
- var upSub = up . ExpectSubscription ( ) ;
297
- upSub . ExpectCancellation ( ) ;
290
+ var upSub = await up . ExpectSubscriptionAsync ( ) ;
291
+ await upSub . ExpectCancellationAsync ( ) ;
298
292
} , Materializer ) ;
299
293
}
300
294
301
295
[ Fact ]
302
- public void A_Broadcast_must_AltoTo_must_broadcast ( )
296
+ public async Task A_Broadcast_must_AltoTo_must_broadcast ( )
303
297
{
304
- this . AssertAllStagesStopped ( ( ) =>
305
- {
298
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
306
299
var p = this . SinkProbe < int > ( ) ;
307
300
var p2 = this . SinkProbe < int > ( ) ;
308
301
@@ -315,20 +308,19 @@ public void A_Broadcast_must_AltoTo_must_broadcast()
315
308
var ps1 = t . Item1 ;
316
309
var ps2 = t . Item2 ;
317
310
318
- ps1 . Request ( 6 ) ;
319
- ps2 . Request ( 6 ) ;
320
- ps1 . ExpectNext ( 1 , 2 , 3 , 4 , 5 , 6 ) ;
321
- ps2 . ExpectNext ( 1 , 2 , 3 , 4 , 5 , 6 ) ;
322
- ps1 . ExpectComplete ( ) ;
323
- ps2 . ExpectComplete ( ) ;
311
+ await ps1 . RequestAsync ( 6 ) ;
312
+ await ps2 . RequestAsync ( 6 ) ;
313
+ ps1 . ExpectNext ( 1 , 2 , 3 , 4 , 5 , 6 ) ;
314
+ ps2 . ExpectNext ( 1 , 2 , 3 , 4 , 5 , 6 ) ;
315
+ await ps1 . ExpectCompleteAsync ( ) ;
316
+ await ps2 . ExpectCompleteAsync ( ) ;
324
317
} , Materializer ) ;
325
318
}
326
319
327
320
[ Fact ]
328
- public void A_Broadcast_must_AlsoTo_must_continue_if_sink_cancels ( )
321
+ public async Task A_Broadcast_must_AlsoTo_must_continue_if_sink_cancels ( )
329
322
{
330
- this . AssertAllStagesStopped ( ( ) =>
331
- {
323
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
332
324
var p = this . SinkProbe < int > ( ) ;
333
325
var p2 = this . SinkProbe < int > ( ) ;
334
326
@@ -340,11 +332,11 @@ public void A_Broadcast_must_AlsoTo_must_continue_if_sink_cancels()
340
332
341
333
var ps1 = t . Item1 ;
342
334
var ps2 = t . Item2 ;
343
-
344
- ps2 . Request ( 6 ) ;
335
+
336
+ await ps2 . RequestAsync ( 6 ) ;
345
337
ps1 . Cancel ( ) ;
346
- ps2 . ExpectNext ( 1 , 2 , 3 , 4 , 5 , 6 ) ;
347
- ps2 . ExpectComplete ( ) ;
338
+ ps2 . ExpectNext ( 1 , 2 , 3 , 4 , 5 , 6 ) ;
339
+ await ps2 . ExpectCompleteAsync ( ) ;
348
340
} , Materializer ) ;
349
341
}
350
342
}
0 commit comments