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

fix: correct poll w/o result #157

Merged
merged 5 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions src/Arcus.Testing.Core/Poll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ namespace Arcus.Testing
/// <typeparam name="TException">The type of exception that is expected to be thrown by the target.</typeparam>
public class Poll<TException> : Poll<int, TException> where TException : Exception
{
internal Poll(Func<Task> getTargetWithoutResultAsync, PollOptions options) : base(() => getTargetWithoutResultAsync().ContinueWith(_ => 0), options)
{
}
internal Poll(Func<Task> getTargetWithoutResultAsync, PollOptions options)
: base(async () => { await getTargetWithoutResultAsync(); return 0; }, options)
{
}
}

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion src/Arcus.Testing.Tests.Unit/Core/PollTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public async Task Poll_WithDiffExceptionThanUnavailableTarget_FailsDirectlyWithD
}

[Fact]
public async Task PollFailure_WithoutResult_ShouldFail()
{
await Assert.ThrowsAsync<TimeoutException>(() => Poll.UntilAvailableAsync(async () => await AlwaysFailsAsync(), MinTimeFrame));
}

[Fact(Skip = "Unreliable on build server")]
public async Task Poll_WithUntilPredicate_SucceedsAfterThirdTime()
{
// Arrange
Expand Down Expand Up @@ -160,7 +166,7 @@ private static void AlwaysSucceeds() { }

private static void SometimesSucceeds()
{
if (Bogus.PickRandom(false, false, true))
if (Bogus.PickRandom(false, false, false, true))
{
throw new TestPollException("Sabotage polling!");
}
Expand Down
Loading