-
Notifications
You must be signed in to change notification settings - Fork 28
[API Proposal]: Assertions to repeatedly execute an action until it succeeds #38
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
Comments
I can see myself using this. Without looking at the implementation, I’d expect it to also support as an example: await myAsyncFunc.Should().SucceedWithinAsync(TimeSpan.FromSeconds(1)).Which.Should().Be(42); I also thought it could take a CancellationToken, but to make it safe, that should probably be handled inside the implementation. |
Should we create a Milestone for 8.1.0? |
Yes, if the |
I'm not sure. I can't tell how long it will take to implement it properly. Also, we should first get the API sound. I have to sort out, how that integrates with the existing |
I removed the |
Added One could also add a Now, the question is also about testability. For the functionality I need an I'm not sure, if we also want an additional public async Task<AndConstraint<TAssertions>> SatisfyWithinAsync<T>(Action<T> assertion, TimeSpan timeOut, IPollingInterval pollingInterval, IClock clock, string because = "", params object[] becauseArgs)
where T : TSubject for testing, and the Setting the issue as ready to review, as now I could need some input on the current status. |
In the |
Hmm, I see. |
Yeah, it seems that the API surface is inconsistent in this regard... |
Ok, so I went through the curren API. GenericCollectionAssertions.SatisfyRespectively(params Action<T>[])
GenericCollectionAssertions.SatisfyRespectively(IEnumerable<Action<T>>)
GenericCollectionAssertions.Satisfy(params Expression<Func<T, bool>>[])
GenericCollectionAssertions.Satisfy(IEnumerable<Expression<Func<T, bool>>>)
GenericCollectionAssertions.AllSatisfy(Action<T>)
ReferenceTypeAssertions.Satisfy<T>(Action<T>)
TypeEnumerableExtensions.ThatSatisfy(this IEnumerable<Type> types, Func<Type, bool> predicate) and for NumericAssertionsBase.Match(Expression<Func<T, bool>>)
EnumAssertions.Match(Expression<Func<TEnum?, bool>>)
ReferenceTypeAssertions.Match<T>(Expression<Func<T, bool>>) If we plan to have both variants with MatchWithin(Func<T, bool>)
MatchWithinAsync(Func<T, Task<bool>>)
SatisfyWithin(Action<T>)
SatisfyWithinAsync(Func<T, Task>) Another point: I don't know why some methods use |
You can use an Nowadays you could use the |
I've just seen, that the |
Background and motivation
I frequently need some kind of testing functionality to wait until a certain condition is fulfilled (similar to awaitility.org).
That could be an addition to the
CompleteWithinAsync
functionality.API Proposal
API Usage
Example 1:
Example 2:
Alternative Designs
No response
Risks
No risks, this does not touch existing API.
Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?
Yes, please assign this issue to me.
The text was updated successfully, but these errors were encountered: