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
Assertions for Task and Task<T> with CompleteWithin checks #1048
Conversation
Today I looked deeper in your PR. In addition to my review comments below, please note the following:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not in the position to "request" changes, but I recommend at least thinking about...
Src/FluentAssertions/Specialized/GenericAsyncFunctionAssertions.cs
Outdated
Show resolved
Hide resolved
Src/FluentAssertions/Specialized/GenericAsyncFunctionAssertions.cs
Outdated
Show resolved
Hide resolved
|
||
namespace FluentAssertions.Specs | ||
{ | ||
public class TaskAssertionSpecs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are testing here Func<Task>
not Task
.
So this tests should be placed in the file for the other Func tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which one do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AsyncFunctionExceptionAssertionSpecs.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspected that one, but that one acts on exceptions, not tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I recommend AsyncMethodAssertionSpecs.cs
here and AsyncFunctionAssertionSpecs.cs
below.
Or - following your implementation classes GenericAsyncFunctionAssertionsSpecs.cs
and NonGenericAsyncFunctionAssertionsSpecs.cs
.
BTW: I myself prefer positive logic. This is why I do not that like "NonGeneric".
|
||
namespace FluentAssertions.Specs | ||
{ | ||
public class TaskOfTAssertionSpecs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So above!
introduce ITimer to abstract real timing in the tests rework after review rework after review Another pass of review.
Of course you are. And you were even right.
I took your PR and implemented it according to the review comment @jnyrup made here and with which I agreed. |
I'm pretty sure it could be a binary compatibility issue. I'm not sure I care enough considering this is not an extension point.
Outlook voor Android downloaden<https://aka.ms/ghei36>
________________________________
From: Jonas Nyrup <notifications@github.com>
Sent: Monday, May 27, 2019 10:00:28 PM
To: fluentassertions/fluentassertions
Cc: Dennis Doomen; Author
Subject: Re: [fluentassertions/fluentassertions] Assertions for Task and Task<T> with CompleteWithin checks (#1048)
@jnyrup commented on this pull request.
________________________________
In Src/FluentAssertions/AssertionExtensions.cs<#1048 (comment)>:
@@ -662,19 +664,19 @@ public static ActionAssertions Should(this Action action)
/// current <see cref="System.Func{Task}"/> .
/// </summary>
[Pure]
- public static AsyncFunctionAssertions Should(this Func<Task> action)
+ public static NonGenericAsyncFunctionAssertions Should(this Func<Task> action)
Wouldn't that other library be able to match it against the base type AsyncFunctionAssertions?
Maybe I'm just to tired to review any more code for today.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#1048?email_source=notifications&email_token=AAEL2PUCFHG4OZJF4K6NSJDPXQ4VZA5CNFSM4HPUXVDKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOBZZGWLI#discussion_r287873393>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AAEL2PVJL3UVWJL762ENLZ3PXQ4VZANCNFSM4HPUXVDA>.
|
/// <param name="becauseArgs"> | ||
/// Zero or more objects to format using the placeholders in <see cref="because" />. | ||
/// </param> | ||
public AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, Task<TResult>> CompleteWithin( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we return TResult
instead of Task<TResult>
?
That would remove the need in tests to call .Result
.
Crap. I was too fast. |
/// <param name="becauseArgs"> | ||
/// Zero or more objects to format using the placeholders in <see cref="because" />. | ||
/// </param> | ||
public AndWhichConstraint<AsyncFunctionAssertions, Task> CompleteWithin( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the other CompleteWithin
is changed to
AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, TResult>
then this should be changed to
AndConstraint<AsyncFunctionAssertions<TResult>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it. They both return AndWhichConstraint
. One just wraps it in Task
.
I was thinking about using AndWhichConstraint<...,TResult> when the subject is e.g. Func<Task> I'm vacationing until Monday without a computer, so my responses might be delayed and inferior. |
Replaces #1013 by applying some more refactoring on #1013.
Thanks to @lg2de for the original implementation.