Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[29-74] FlowSkipWhileSpec #6576

Merged
merged 8 commits into from
Apr 7, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 43 additions & 46 deletions src/core/Akka.Streams.Tests/Dsl/FlowSkipWhileSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Akka.Streams.Dsl;
using Akka.Streams.Supervision;
using Akka.Streams.TestKit;
Expand All @@ -28,68 +29,64 @@ public FlowSkipWhileSpec(ITestOutputHelper helper) : base(helper)
}

[Fact]
public void A_SkipWhile_must_skip_while_predicate_is_true()
public async Task A_SkipWhile_must_skip_while_predicate_is_true()
{
this.AssertAllStagesStopped(() =>
{
Source.From(Enumerable.Range(1, 4))
.SkipWhile(x => x < 3)
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(2)
.ExpectNext( 3, 4)
.ExpectComplete();
await this.AssertAllStagesStoppedAsync(async() => {
await Source.From(Enumerable.Range(1, 4))
.SkipWhile(x => x < 3)
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(2)
.ExpectNext(3, 4)
.ExpectCompleteAsync();
}, Materializer);
}

[Fact]
public void A_SkipWhile_must_complete_the_future_for_an_empty_stream()
public async Task A_SkipWhile_must_complete_the_future_for_an_empty_stream()
{
this.AssertAllStagesStopped(() =>
{
Source.Empty<int>()
.SkipWhile(x => x < 2)
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(1)
.ExpectComplete();
await this.AssertAllStagesStoppedAsync(async() => {
await Source.Empty<int>()
.SkipWhile(x => x < 2)
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(1)
.ExpectCompleteAsync();
}, Materializer);
}

[Fact]
public void A_SkipWhile_must_continue_if_error()
public async Task A_SkipWhile_must_continue_if_error()
{
this.AssertAllStagesStopped(() =>
{
Source.From(Enumerable.Range(1, 4)).SkipWhile(x =>
{
if (x < 3)
return true;
throw new TestException("");
})
.WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.ResumingDecider))
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(1)
.ExpectComplete();
await this.AssertAllStagesStoppedAsync(async() => {
await Source.From(Enumerable.Range(1, 4)).SkipWhile(x =>
{
if (x < 3)
return true;
throw new TestException("");
})
.WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.ResumingDecider))
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(1)
.ExpectCompleteAsync();
}, Materializer);
}

[Fact]
public void A_SkipWhile_must_restart_with_strategy()
public async Task A_SkipWhile_must_restart_with_strategy()
{
this.AssertAllStagesStopped(() =>
{
Source.From(Enumerable.Range(1, 4)).SkipWhile(x =>
{
if (x == 1 || x == 3)
return true;
if (x == 4)
return false;
throw new TestException("");
})
.WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.RestartingDecider))
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(1)
.ExpectNext(4)
.ExpectComplete();
await this.AssertAllStagesStoppedAsync(async() => {
await Source.From(Enumerable.Range(1, 4)).SkipWhile(x =>
{
if (x == 1 || x == 3)
return true;
if (x == 4)
return false;
throw new TestException("");
})
.WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.RestartingDecider))
.RunWith(this.SinkProbe<int>(), Materializer)
.Request(1)
.ExpectNext(4)
.ExpectCompleteAsync();
}, Materializer);
}
}
Expand Down