6
6
//-----------------------------------------------------------------------
7
7
8
8
using System ;
9
+ using System . Threading . Tasks ;
9
10
using Akka . Actor ;
10
11
using Akka . Streams . Dsl ;
11
12
using Akka . Streams . TestKit ;
@@ -25,66 +26,62 @@ public FlowOnCompleteSpec(ITestOutputHelper helper) : base(helper)
25
26
}
26
27
27
28
[ Fact ]
28
- public void A_Flow_with_OnComplete_must_invoke_callback_on_normal_completion ( )
29
+ public async Task A_Flow_with_OnComplete_must_invoke_callback_on_normal_completion ( )
29
30
{
30
- this . AssertAllStagesStopped ( ( ) =>
31
- {
31
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
32
32
var onCompleteProbe = CreateTestProbe ( ) ;
33
33
var p = this . CreateManualPublisherProbe < int > ( ) ;
34
34
Source . FromPublisher ( p )
35
35
. To ( Sink . OnComplete < int > ( ( ) => onCompleteProbe . Ref . Tell ( "done" ) , _ => { } ) )
36
36
. Run ( Materializer ) ;
37
- var proc = p . ExpectSubscription ( ) ;
38
- proc . ExpectRequest ( ) ;
37
+ var proc = await p . ExpectSubscriptionAsync ( ) ;
38
+ await proc . ExpectRequestAsync ( ) ;
39
39
proc . SendNext ( 42 ) ;
40
- onCompleteProbe . ExpectNoMsg ( TimeSpan . FromMilliseconds ( 100 ) ) ;
40
+ await onCompleteProbe . ExpectNoMsgAsync ( TimeSpan . FromMilliseconds ( 100 ) ) ;
41
41
proc . SendComplete ( ) ;
42
- onCompleteProbe . ExpectMsg ( "done" ) ;
42
+ await onCompleteProbe . ExpectMsgAsync ( "done" ) ;
43
43
} , Materializer ) ;
44
44
}
45
45
46
46
[ Fact ]
47
- public void A_Flow_with_OnComplete_must_yield_the_first_error ( )
47
+ public async Task A_Flow_with_OnComplete_must_yield_the_first_error ( )
48
48
{
49
- this . AssertAllStagesStopped ( ( ) =>
50
- {
49
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
51
50
var onCompleteProbe = CreateTestProbe ( ) ;
52
51
var p = this . CreateManualPublisherProbe < int > ( ) ;
53
52
Source . FromPublisher ( p )
54
53
. To ( Sink . OnComplete < int > ( ( ) => { } , ex => onCompleteProbe . Ref . Tell ( ex ) ) )
55
54
. Run ( Materializer ) ;
56
- var proc = p . ExpectSubscription ( ) ;
57
- proc . ExpectRequest ( ) ;
55
+ var proc = await p . ExpectSubscriptionAsync ( ) ;
56
+ await proc . ExpectRequestAsync ( ) ;
58
57
var cause = new TestException ( "test" ) ;
59
58
proc . SendError ( cause ) ;
60
- onCompleteProbe . ExpectMsg ( cause ) ;
61
- onCompleteProbe . ExpectNoMsg ( TimeSpan . FromMilliseconds ( 100 ) ) ;
59
+ await onCompleteProbe . ExpectMsgAsync ( cause ) ;
60
+ await onCompleteProbe . ExpectNoMsgAsync ( TimeSpan . FromMilliseconds ( 100 ) ) ;
62
61
} , Materializer ) ;
63
62
}
64
63
65
64
[ Fact ]
66
- public void A_Flow_with_OnComplete_must_invoke_callback_for_an_empty_stream ( )
65
+ public async Task A_Flow_with_OnComplete_must_invoke_callback_for_an_empty_stream ( )
67
66
{
68
- this . AssertAllStagesStopped ( ( ) =>
69
- {
67
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
70
68
var onCompleteProbe = CreateTestProbe ( ) ;
71
69
var p = this . CreateManualPublisherProbe < int > ( ) ;
72
70
Source . FromPublisher ( p )
73
71
. To ( Sink . OnComplete < int > ( ( ) => onCompleteProbe . Ref . Tell ( "done" ) , _ => { } ) )
74
72
. Run ( Materializer ) ;
75
- var proc = p . ExpectSubscription ( ) ;
76
- proc . ExpectRequest ( ) ;
73
+ var proc = await p . ExpectSubscriptionAsync ( ) ;
74
+ await proc . ExpectRequestAsync ( ) ;
77
75
proc . SendComplete ( ) ;
78
- onCompleteProbe . ExpectMsg ( "done" ) ;
79
- onCompleteProbe . ExpectNoMsg ( TimeSpan . FromMilliseconds ( 100 ) ) ;
76
+ await onCompleteProbe . ExpectMsgAsync ( "done" ) ;
77
+ await onCompleteProbe . ExpectNoMsgAsync ( TimeSpan . FromMilliseconds ( 100 ) ) ;
80
78
} , Materializer ) ;
81
79
}
82
80
83
81
[ Fact ]
84
- public void A_Flow_with_OnComplete_must_invoke_callback_after_transform_and_foreach_steps ( )
82
+ public async Task A_Flow_with_OnComplete_must_invoke_callback_after_transform_and_foreach_steps ( )
85
83
{
86
- this . AssertAllStagesStopped ( ( ) =>
87
- {
84
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
88
85
var onCompleteProbe = CreateTestProbe ( ) ;
89
86
var p = this . CreateManualPublisherProbe < int > ( ) ;
90
87
var foreachSink = Sink . ForEach < int > ( x => onCompleteProbe . Ref . Tell ( "foreach-" + x ) ) ;
@@ -95,18 +92,19 @@ public void A_Flow_with_OnComplete_must_invoke_callback_after_transform_and_fore
95
92
} ) . RunWith ( foreachSink , Materializer ) ;
96
93
future . ContinueWith ( t => onCompleteProbe . Tell ( t . IsCompleted ? "done" : "failure" ) ) ;
97
94
98
- var proc = p . ExpectSubscription ( ) ;
99
- proc . ExpectRequest ( ) ;
95
+ var proc = await p . ExpectSubscriptionAsync ( ) ;
96
+ await proc . ExpectRequestAsync ( ) ;
100
97
proc . SendNext ( 42 ) ;
101
98
proc . SendComplete ( ) ;
102
- onCompleteProbe . ExpectMsg ( "map-42" ) ;
103
- onCompleteProbe . ExpectMsg ( "foreach-42" ) ;
104
- onCompleteProbe . ExpectMsg ( "done" ) ;
99
+ await onCompleteProbe . ExpectMsgAsync ( "map-42" ) ;
100
+ await onCompleteProbe . ExpectMsgAsync ( "foreach-42" ) ;
101
+ await onCompleteProbe . ExpectMsgAsync ( "done" ) ;
102
+
105
103
} , Materializer ) ;
106
104
}
107
105
108
106
[ Fact ]
109
- public void A_Flow_with_OnComplete_must_yield_error_on_abrupt_termination ( )
107
+ public async Task A_Flow_with_OnComplete_must_yield_error_on_abrupt_termination ( )
110
108
{
111
109
var materializer = ActorMaterializer . Create ( Sys ) ;
112
110
var onCompleteProbe = CreateTestProbe ( ) ;
@@ -115,11 +113,11 @@ public void A_Flow_with_OnComplete_must_yield_error_on_abrupt_termination()
115
113
Source . FromPublisher ( publisher ) . To ( Sink . OnComplete < int > ( ( ) => onCompleteProbe . Ref . Tell ( "done" ) ,
116
114
ex => onCompleteProbe . Ref . Tell ( ex ) ) )
117
115
. Run ( materializer ) ;
118
- var proc = publisher . ExpectSubscription ( ) ;
119
- proc . ExpectRequest ( ) ;
116
+ var proc = await publisher . ExpectSubscriptionAsync ( ) ;
117
+ await proc . ExpectRequestAsync ( ) ;
120
118
materializer . Shutdown ( ) ;
121
119
122
- onCompleteProbe . ExpectMsg < AbruptTerminationException > ( ) ;
120
+ await onCompleteProbe . ExpectMsgAsync < AbruptTerminationException > ( ) ;
123
121
}
124
122
}
125
123
}
0 commit comments