Skip to content

Commit 7472bd5

Browse files
eabaAaronontheweb
andauthored
[69-74] KeepGoingStageSpec (#6617)
* [69-74] `KeepGoingStageSpec` * Changes --------- Co-authored-by: Aaron Stannard <[email protected]>
1 parent 40fdc1b commit 7472bd5

File tree

1 file changed

+39
-45
lines changed

1 file changed

+39
-45
lines changed

src/core/Akka.Streams.Tests/Implementation/Fusing/KeepGoingStageSpec.cs

+39-45
Original file line numberDiff line numberDiff line change
@@ -200,143 +200,137 @@ public KeepGoingStageSpec(ITestOutputHelper helper = null) : base(helper)
200200
}
201201

202202
[Fact]
203-
public void A_stage_with_keep_going_must_still_be_alive_after_all_ports_have_been_closed_until_explicity_closed()
203+
public async Task A_stage_with_keep_going_must_still_be_alive_after_all_ports_have_been_closed_until_explicity_closed()
204204
{
205-
this.AssertAllStagesStopped(() =>
206-
{
205+
await this.AssertAllStagesStoppedAsync(async() => {
207206
var t = Source.Maybe<int>().ToMaterialized(new PingableSink(true), Keep.Both).Run(Materializer);
208207
var maybePromise = t.Item1;
209208
var pingerFuture = t.Item2;
210209
pingerFuture.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
211-
var pinger = pingerFuture.Result;
210+
var pinger = await pingerFuture;
212211

213212
pinger.Register(TestActor);
214213

215214
//Before completion
216215
pinger.Ping();
217-
ExpectMsg<Pong>();
216+
await ExpectMsgAsync<Pong>();
218217

219218
pinger.Ping();
220-
ExpectMsg<Pong>();
219+
await ExpectMsgAsync<Pong>();
221220

222221
maybePromise.TrySetResult(0);
223-
ExpectMsg<UpstreamCompleted>();
222+
await ExpectMsgAsync<UpstreamCompleted>();
224223

225-
ExpectNoMsg(200);
224+
await ExpectNoMsgAsync(200);
226225

227226
pinger.Ping();
228-
ExpectMsg<Pong>();
227+
await ExpectMsgAsync<Pong>();
229228

230229
pinger.Stop();
231230
// PostStop should not be concurrent with the event handler. This event here tests this.
232-
ExpectMsg<EndOfEventHandler>();
233-
ExpectMsg<PostStop>();
231+
await ExpectMsgAsync<EndOfEventHandler>();
232+
await ExpectMsgAsync<PostStop>();
234233
}, Materializer);
235234
}
236235

237236
[Fact]
238-
public void A_stage_with_keep_going_must_still_be_alive_after_all_ports_have_been_closed_until_explicitly_failed()
237+
public async Task A_stage_with_keep_going_must_still_be_alive_after_all_ports_have_been_closed_until_explicitly_failed()
239238
{
240-
this.AssertAllStagesStopped(() =>
241-
{
239+
await this.AssertAllStagesStoppedAsync(async() => {
242240
var t = Source.Maybe<int>().ToMaterialized(new PingableSink(true), Keep.Both).Run(Materializer);
243241
var maybePromise = t.Item1;
244242
var pingerFuture = t.Item2;
245243
pingerFuture.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
246-
var pinger = pingerFuture.Result;
244+
var pinger = await pingerFuture;
247245

248246
pinger.Register(TestActor);
249247

250248
//Before completion
251249
pinger.Ping();
252-
ExpectMsg<Pong>();
250+
await ExpectMsgAsync<Pong>();
253251

254252
pinger.Ping();
255-
ExpectMsg<Pong>();
253+
await ExpectMsgAsync<Pong>();
256254

257255
maybePromise.TrySetResult(0);
258-
ExpectMsg<UpstreamCompleted>();
256+
await ExpectMsgAsync<UpstreamCompleted>();
259257

260-
ExpectNoMsg(200);
258+
await ExpectNoMsgAsync(200);
261259

262260
pinger.Ping();
263-
ExpectMsg<Pong>();
261+
await ExpectMsgAsync<Pong>();
264262

265263
pinger.Ping();
266-
ExpectMsg<Pong>();
264+
await ExpectMsgAsync<Pong>();
267265

268266
pinger.Fail();
269267
// PostStop should not be concurrent with the event handler. This event here tests this.
270-
ExpectMsg<EndOfEventHandler>();
271-
ExpectMsg<PostStop>();
272-
268+
await ExpectMsgAsync<EndOfEventHandler>();
269+
await ExpectMsgAsync<PostStop>();
273270
}, Materializer);
274271
}
275272

276273
[Fact]
277-
public void A_stage_with_keep_going_must_still_be_alive_after_all_ports_have_been_closed_until_implicity_failed_via_exception()
274+
public async Task A_stage_with_keep_going_must_still_be_alive_after_all_ports_have_been_closed_until_implicity_failed_via_exception()
278275
{
279-
this.AssertAllStagesStopped(() =>
280-
{
276+
await this.AssertAllStagesStoppedAsync(async() => {
281277
var t = Source.Maybe<int>().ToMaterialized(new PingableSink(true), Keep.Both).Run(Materializer);
282278
var maybePromise = t.Item1;
283279
var pingerFuture = t.Item2;
284280
pingerFuture.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
285-
var pinger = pingerFuture.Result;
281+
var pinger = await pingerFuture;
286282

287283
pinger.Register(TestActor);
288284

289285
//Before completion
290286
pinger.Ping();
291-
ExpectMsg<Pong>();
287+
await ExpectMsgAsync<Pong>();
292288

293289
pinger.Ping();
294-
ExpectMsg<Pong>();
290+
await ExpectMsgAsync<Pong>();
295291

296292
maybePromise.TrySetResult(0);
297-
ExpectMsg<UpstreamCompleted>();
293+
await ExpectMsgAsync<UpstreamCompleted>();
298294

299295
ExpectNoMsg(200);
300296

301297
pinger.Ping();
302-
ExpectMsg<Pong>();
298+
await ExpectMsgAsync<Pong>();
303299

304300
pinger.Ping();
305-
ExpectMsg<Pong>();
301+
await ExpectMsgAsync<Pong>();
306302

307303
// We need to catch the exception otherwise the test fails
308304
// ReSharper disable once EmptyGeneralCatchClause
309-
try { pinger.ThrowEx();} catch { }
305+
try { pinger.ThrowEx(); } catch { }
310306
// PostStop should not be concurrent with the event handler. This event here tests this.
311-
ExpectMsg<EndOfEventHandler>();
312-
ExpectMsg<PostStop>();
313-
307+
await ExpectMsgAsync<EndOfEventHandler>();
308+
await ExpectMsgAsync<PostStop>();
314309
}, Materializer);
315310
}
316311

317312
[Fact]
318-
public void A_stage_with_keep_going_must_close_down_earls_if_keepAlive_is_not_requested()
313+
public async Task A_stage_with_keep_going_must_close_down_earls_if_keepAlive_is_not_requested()
319314
{
320-
this.AssertAllStagesStopped(() =>
321-
{
315+
await this.AssertAllStagesStoppedAsync(async() => {
322316
var t = Source.Maybe<int>().ToMaterialized(new PingableSink(false), Keep.Both).Run(Materializer);
323317
var maybePromise = t.Item1;
324318
var pingerFuture = t.Item2;
325319
pingerFuture.Wait(TimeSpan.FromSeconds(3)).Should().BeTrue();
326-
var pinger = pingerFuture.Result;
320+
var pinger = await pingerFuture;
327321

328322
pinger.Register(TestActor);
329323

330324
//Before completion
331325
pinger.Ping();
332-
ExpectMsg<Pong>();
326+
await ExpectMsgAsync<Pong>();
333327

334328
pinger.Ping();
335-
ExpectMsg<Pong>();
329+
await ExpectMsgAsync<Pong>();
336330

337331
maybePromise.TrySetResult(0);
338-
ExpectMsg<UpstreamCompleted>();
339-
ExpectMsg<PostStop>();
332+
await ExpectMsgAsync<UpstreamCompleted>();
333+
await ExpectMsgAsync<PostStop>();
340334
}, Materializer);
341335
}
342336
}

0 commit comments

Comments
 (0)