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

Assertions for Task and Task<T> with CompleteWithin checks #1048

Merged
merged 1 commit into from
May 28, 2019

Conversation

dennisdoomen
Copy link
Member

@dennisdoomen dennisdoomen commented May 25, 2019

Replaces #1013 by applying some more refactoring on #1013.

Thanks to @lg2de for the original implementation.

@lg2de
Copy link
Contributor

lg2de commented May 27, 2019

Today I looked deeper in your PR. In addition to my review comments below, please note the following:

Copy link
Contributor

@lg2de lg2de left a 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...


namespace FluentAssertions.Specs
{
public class TaskAssertionSpecs
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AsyncFunctionExceptionAssertionSpecs.cs

Copy link
Member Author

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.

Copy link
Contributor

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
Copy link
Contributor

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.
@dennisdoomen
Copy link
Member Author

I'm not in the position to "request" changes, but I recommend at least thinking about...

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.

@dennisdoomen
Copy link
Member Author

dennisdoomen commented May 27, 2019 via email

@dennisdoomen dennisdoomen merged commit 4009f5e into fluentassertions:master May 28, 2019
@dennisdoomen dennisdoomen deleted the Rework1013 branch May 28, 2019 06:11
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <see cref="because" />.
/// </param>
public AndWhichConstraint<GenericAsyncFunctionAssertions<TResult>, Task<TResult>> CompleteWithin(
Copy link
Member

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.

@dennisdoomen
Copy link
Member Author

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(
Copy link
Member

@jnyrup jnyrup Jun 7, 2019

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>>

Copy link
Member Author

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.

@jnyrup
Copy link
Member

jnyrup commented Jun 7, 2019

I was thinking about using AndWhichConstraint<...,TResult> when the subject is e.g. Func<Task>
and AndConstraint<...> when the Subject is e.g. Func.

I'm vacationing until Monday without a computer, so my responses might be delayed and inferior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants