@@ -38,10 +38,9 @@ public QueueSinkSpec(ITestOutputHelper output) : base(output)
38
38
}
39
39
40
40
[ Fact ]
41
- public void QueueSink_should_send_the_elements_as_result_of_future ( )
41
+ public async Task QueueSink_should_send_the_elements_as_result_of_future ( )
42
42
{
43
- this . AssertAllStagesStopped ( ( ) =>
44
- {
43
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
45
44
var expected = new List < Option < int > >
46
45
{
47
46
Option < int > . Create ( 1 ) ,
@@ -52,19 +51,18 @@ public void QueueSink_should_send_the_elements_as_result_of_future()
52
51
var queue = Source . From ( expected . Where ( o => o . HasValue ) . Select ( o => o . Value ) )
53
52
. RunWith ( Sink . Queue < int > ( ) , _materializer ) ;
54
53
55
- expected . ForEach ( v =>
54
+ foreach ( var v in expected )
56
55
{
57
56
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
58
- ExpectMsg ( v ) ;
59
- } ) ;
57
+ await ExpectMsgAsync ( v ) ;
58
+ } ;
60
59
} , _materializer ) ;
61
60
}
62
61
63
62
[ Fact ]
64
- public void QueueSink_should_allow_to_have_only_one_future_waiting_for_result_in_each_point_in_time ( )
63
+ public async Task QueueSink_should_allow_to_have_only_one_future_waiting_for_result_in_each_point_in_time ( )
65
64
{
66
- this . AssertAllStagesStopped ( ( ) =>
67
- {
65
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
68
66
var probe = this . CreateManualPublisherProbe < int > ( ) ;
69
67
var queue = Source . FromPublisher ( probe ) . RunWith ( Sink . Queue < int > ( ) , _materializer ) ;
70
68
var sub = probe . ExpectSubscription ( ) ;
@@ -74,58 +72,55 @@ public void QueueSink_should_allow_to_have_only_one_future_waiting_for_result_in
74
72
75
73
sub . SendNext ( 1 ) ;
76
74
future . PipeTo ( TestActor ) ;
77
- ExpectMsg ( Option < int > . Create ( 1 ) ) ;
75
+ await ExpectMsgAsync ( Option < int > . Create ( 1 ) ) ;
78
76
79
77
sub . SendComplete ( ) ;
80
- queue . PullAsync ( ) ;
78
+ await queue . PullAsync ( ) ;
81
79
} , _materializer ) ;
82
80
}
83
81
84
82
[ Fact ]
85
- public void QueueSink_should_wait_for_next_element_from_upstream ( )
83
+ public async Task QueueSink_should_wait_for_next_element_from_upstream ( )
86
84
{
87
- this . AssertAllStagesStopped ( ( ) =>
88
- {
85
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
89
86
var probe = this . CreateManualPublisherProbe < int > ( ) ;
90
87
var queue = Source . FromPublisher ( probe ) . RunWith ( Sink . Queue < int > ( ) , _materializer ) ;
91
88
var sub = probe . ExpectSubscription ( ) ;
92
89
93
90
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
94
- ExpectNoMsg ( _pause ) ;
91
+ await ExpectNoMsgAsync ( _pause ) ;
95
92
96
93
sub . SendNext ( 1 ) ;
97
- ExpectMsg ( Option < int > . Create ( 1 ) ) ;
94
+ await ExpectMsgAsync ( Option < int > . Create ( 1 ) ) ;
98
95
sub . SendComplete ( ) ;
99
- queue . PullAsync ( ) ;
96
+ await queue . PullAsync ( ) ;
100
97
} , _materializer ) ;
101
98
}
102
99
103
100
[ Fact ]
104
- public void QueueSink_should_fail_future_on_stream_failure ( )
101
+ public async Task QueueSink_should_fail_future_on_stream_failure ( )
105
102
{
106
- this . AssertAllStagesStopped ( ( ) =>
107
- {
103
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
108
104
var probe = this . CreateManualPublisherProbe < int > ( ) ;
109
105
var queue = Source . FromPublisher ( probe ) . RunWith ( Sink . Queue < int > ( ) , _materializer ) ;
110
- var sub = probe . ExpectSubscription ( ) ;
106
+ var sub = await probe . ExpectSubscriptionAsync ( ) ;
111
107
112
108
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
113
- ExpectNoMsg ( _pause ) ;
109
+ await ExpectNoMsgAsync ( _pause ) ;
114
110
115
111
sub . SendError ( TestException ( ) ) ;
116
- ExpectMsg < Status . Failure > (
112
+ await ExpectMsgAsync < Status . Failure > (
117
113
f => f . Cause . Equals ( TestException ( ) ) ) ;
118
114
} , _materializer ) ;
119
115
}
120
116
121
117
[ Fact ]
122
- public void QueueSink_should_fail_future_when_stream_failed ( )
118
+ public async Task QueueSink_should_fail_future_when_stream_failed ( )
123
119
{
124
- this . AssertAllStagesStopped ( ( ) =>
125
- {
120
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
126
121
var probe = this . CreateManualPublisherProbe < int > ( ) ;
127
122
var queue = Source . FromPublisher ( probe ) . RunWith ( Sink . Queue < int > ( ) , _materializer ) ;
128
- var sub = probe . ExpectSubscription ( ) ;
123
+ var sub = await probe . ExpectSubscriptionAsync ( ) ;
129
124
130
125
sub . SendError ( TestException ( ) ) ;
131
126
queue . Invoking ( q => q . PullAsync ( ) . Wait ( RemainingOrDefault ) )
@@ -134,51 +129,48 @@ public void QueueSink_should_fail_future_when_stream_failed()
134
129
}
135
130
136
131
[ Fact ]
137
- public void QueueSink_should_timeout_future_when_stream_cannot_provide_data ( )
132
+ public async Task QueueSink_should_timeout_future_when_stream_cannot_provide_data ( )
138
133
{
139
- this . AssertAllStagesStopped ( ( ) =>
140
- {
134
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
141
135
var probe = this . CreateManualPublisherProbe < int > ( ) ;
142
136
var queue = Source . FromPublisher ( probe ) . RunWith ( Sink . Queue < int > ( ) , _materializer ) ;
143
- var sub = probe . ExpectSubscription ( ) ;
137
+ var sub = await probe . ExpectSubscriptionAsync ( ) ;
144
138
145
139
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
146
- ExpectNoMsg ( _pause ) ;
140
+ await ExpectNoMsgAsync ( _pause ) ;
147
141
148
142
sub . SendNext ( 1 ) ;
149
- ExpectMsg ( Option < int > . Create ( 1 ) ) ;
143
+ await ExpectMsgAsync ( Option < int > . Create ( 1 ) ) ;
150
144
sub . SendComplete ( ) ;
151
- queue . PullAsync ( ) ;
145
+ await queue . PullAsync ( ) ;
152
146
} , _materializer ) ;
153
147
}
154
148
155
149
[ Fact ]
156
- public void QueueSink_should_fail_pull_future_when_stream_is_completed ( )
150
+ public async Task QueueSink_should_fail_pull_future_when_stream_is_completed ( )
157
151
{
158
- this . AssertAllStagesStopped ( ( ) =>
159
- {
152
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
160
153
var probe = this . CreateManualPublisherProbe < int > ( ) ;
161
154
var queue = Source . FromPublisher ( probe ) . RunWith ( Sink . Queue < int > ( ) , _materializer ) ;
162
- var sub = probe . ExpectSubscription ( ) ;
155
+ var sub = await probe . ExpectSubscriptionAsync ( ) ;
163
156
164
157
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
165
158
sub . SendNext ( 1 ) ;
166
- ExpectMsg ( Option < int > . Create ( 1 ) ) ;
159
+ await ExpectMsgAsync ( Option < int > . Create ( 1 ) ) ;
167
160
168
161
sub . SendComplete ( ) ;
169
- var result = queue . PullAsync ( ) . Result ;
162
+ var result = await queue . PullAsync ( ) ;
170
163
result . Should ( ) . Be ( Option < int > . None ) ;
171
164
172
- var exception = Record . ExceptionAsync ( async ( ) => await queue . PullAsync ( ) ) . Result ;
165
+ var exception = await Record . ExceptionAsync ( async ( ) => await queue . PullAsync ( ) ) ;
173
166
exception . Should ( ) . BeOfType < StreamDetachedException > ( ) ;
174
167
} , _materializer ) ;
175
168
}
176
169
177
170
[ Fact ]
178
- public void QueueSink_should_keep_on_sending_even_after_the_buffer_has_been_full ( )
171
+ public async Task QueueSink_should_keep_on_sending_even_after_the_buffer_has_been_full ( )
179
172
{
180
- this . AssertAllStagesStopped ( ( ) =>
181
- {
173
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
182
174
const int bufferSize = 16 ;
183
175
const int streamElementCount = bufferSize + 4 ;
184
176
var sink = Sink . Queue < int > ( ) . WithAttributes ( Attributes . CreateInputBuffer ( bufferSize , bufferSize ) ) ;
@@ -195,31 +187,30 @@ public void QueueSink_should_keep_on_sending_even_after_the_buffer_has_been_full
195
187
for ( var i = 1 ; i <= streamElementCount ; i ++ )
196
188
{
197
189
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
198
- ExpectMsg ( Option < int > . Create ( i ) ) ;
190
+ await ExpectMsgAsync ( Option < int > . Create ( i ) ) ;
199
191
}
200
192
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
201
- ExpectMsg ( Option < int > . None ) ;
193
+ await ExpectMsgAsync ( Option < int > . None ) ;
202
194
} , _materializer ) ;
203
195
}
204
196
205
197
[ Fact ]
206
- public void QueueSink_should_work_with_one_element_buffer ( )
198
+ public async Task QueueSink_should_work_with_one_element_buffer ( )
207
199
{
208
- this . AssertAllStagesStopped ( ( ) =>
209
- {
200
+ await this . AssertAllStagesStoppedAsync ( async ( ) => {
210
201
var sink = Sink . Queue < int > ( ) . WithAttributes ( Attributes . CreateInputBuffer ( 1 , 1 ) ) ;
211
202
var probe = this . CreateManualPublisherProbe < int > ( ) ;
212
203
var queue = Source . FromPublisher ( probe ) . RunWith ( sink , _materializer ) ;
213
- var sub = probe . ExpectSubscription ( ) ;
204
+ var sub = await probe . ExpectSubscriptionAsync ( ) ;
214
205
215
206
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
216
207
sub . SendNext ( 1 ) ; // should pull next element
217
- ExpectMsg ( Option < int > . Create ( 1 ) ) ;
208
+ await ExpectMsgAsync ( Option < int > . Create ( 1 ) ) ;
218
209
219
210
queue . PullAsync ( ) . PipeTo ( TestActor ) ;
220
- ExpectNoMsg ( ) ; // element requested but buffer empty
211
+ await ExpectNoMsgAsync ( ) ; // element requested but buffer empty
221
212
sub . SendNext ( 2 ) ;
222
- ExpectMsg ( Option < int > . Create ( 2 ) ) ;
213
+ await ExpectMsgAsync ( Option < int > . Create ( 2 ) ) ;
223
214
224
215
sub . SendComplete ( ) ;
225
216
var future = queue . PullAsync ( ) ;
0 commit comments