7
7
8
8
using System . Linq ;
9
9
using System . Threading ;
10
+ using System . Threading . Tasks ;
10
11
using Akka . Streams . Dsl ;
11
12
using Akka . Streams . TestKit ;
12
13
using Akka . Streams . Util ;
@@ -31,72 +32,68 @@ public FlowRecoverSpec(ITestOutputHelper helper) : base(helper)
31
32
private static readonly TestException Ex = new TestException ( "test" ) ;
32
33
33
34
[ Fact ]
34
- public void A_Recover_must_recover_when_there_is_a_handler ( )
35
+ public async Task A_Recover_must_recover_when_there_is_a_handler ( )
35
36
{
36
- this . AssertAllStagesStopped ( ( ) =>
37
- {
38
- Source . From ( Enumerable . Range ( 1 , 4 ) ) . Select ( x =>
39
- {
40
- if ( x == 3 )
41
- throw Ex ;
42
- return x ;
43
- } )
44
- . Recover ( _ => Option < int > . Create ( 0 ) )
45
- . RunWith ( this . SinkProbe < int > ( ) , Materializer )
46
- . RequestNext ( 1 )
47
- . RequestNext ( 2 )
48
- . RequestNext ( 0 )
49
- . Request ( 1 )
50
- . ExpectComplete ( ) ;
51
-
37
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
38
+ await Source . From ( Enumerable . Range ( 1 , 4 ) ) . Select ( x =>
39
+ {
40
+ if ( x == 3 )
41
+ throw Ex ;
42
+ return x ;
43
+ } )
44
+ . Recover ( _ => Option < int > . Create ( 0 ) )
45
+ . RunWith ( this . SinkProbe < int > ( ) , Materializer )
46
+ . RequestNext ( 1 )
47
+ . RequestNext ( 2 )
48
+ . RequestNext ( 0 )
49
+ . Request ( 1 )
50
+ . ExpectCompleteAsync ( ) ;
52
51
} , Materializer ) ;
53
52
}
54
53
55
54
[ Fact ]
56
- public void A_Recover_must_failed_stream_if_handler_is_not_for_such_exception_type ( )
55
+ public async Task A_Recover_must_failed_stream_if_handler_is_not_for_such_exception_type ( )
57
56
{
58
- this . AssertAllStagesStopped ( ( ) =>
59
- {
60
- Source . From ( Enumerable . Range ( 1 , 3 ) ) . Select ( x =>
61
- {
62
- if ( x == 2 )
63
- throw Ex ;
64
- return x ;
65
- } )
66
- . Recover ( _ => Option < int > . None )
67
- . RunWith ( this . SinkProbe < int > ( ) , Materializer )
68
- . RequestNext ( 1 )
69
- . Request ( 1 )
70
- . ExpectError ( ) . Should ( ) . Be ( Ex ) ;
57
+ await this . AssertAllStagesStoppedAsync ( ( ) => {
58
+ Source . From ( Enumerable . Range ( 1 , 3 ) ) . Select ( x =>
59
+ {
60
+ if ( x == 2 )
61
+ throw Ex ;
62
+ return x ;
63
+ } )
64
+ . Recover ( _ => Option < int > . None )
65
+ . RunWith ( this . SinkProbe < int > ( ) , Materializer )
66
+ . RequestNext ( 1 )
67
+ . Request ( 1 )
68
+ . ExpectError ( ) . Should ( ) . Be ( Ex ) ;
69
+ return Task . CompletedTask ;
71
70
} , Materializer ) ;
72
71
}
73
72
74
73
[ Fact ]
75
- public void A_Recover_must_not_influence_stream_when_there_is_no_exception ( )
74
+ public async Task A_Recover_must_not_influence_stream_when_there_is_no_exception ( )
76
75
{
77
- this . AssertAllStagesStopped ( ( ) =>
78
- {
79
- Source . From ( Enumerable . Range ( 1 , 3 ) )
80
- . Select ( x => x )
81
- . Recover ( _ => Option < int > . Create ( 0 ) )
82
- . RunWith ( this . SinkProbe < int > ( ) , Materializer )
83
- . Request ( 3 )
84
- . ExpectNext ( 1 , 2 , 3 )
85
- . ExpectComplete ( ) ;
76
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
77
+ await Source . From ( Enumerable . Range ( 1 , 3 ) )
78
+ . Select ( x => x )
79
+ . Recover ( _ => Option < int > . Create ( 0 ) )
80
+ . RunWith ( this . SinkProbe < int > ( ) , Materializer )
81
+ . Request ( 3 )
82
+ . ExpectNext ( 1 , 2 , 3 )
83
+ . ExpectCompleteAsync ( ) ;
86
84
} , Materializer ) ;
87
85
}
88
86
89
87
[ Fact ]
90
- public void A_Recover_must_finish_stream_if_it_is_empty ( )
88
+ public async Task A_Recover_must_finish_stream_if_it_is_empty ( )
91
89
{
92
- this . AssertAllStagesStopped ( ( ) =>
93
- {
94
- Source . Empty < int > ( )
95
- . Select ( x => x )
96
- . Recover ( _ => Option < int > . Create ( 0 ) )
97
- . RunWith ( this . SinkProbe < int > ( ) , Materializer )
98
- . Request ( 1 )
99
- . ExpectComplete ( ) ;
90
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
91
+ await Source . Empty < int > ( )
92
+ . Select ( x => x )
93
+ . Recover ( _ => Option < int > . Create ( 0 ) )
94
+ . RunWith ( this . SinkProbe < int > ( ) , Materializer )
95
+ . Request ( 1 )
96
+ . ExpectCompleteAsync ( ) ;
100
97
} , Materializer ) ;
101
98
}
102
99
}
0 commit comments