Skip to content

Conversation

@davidomid
Copy link
Contributor

@davidomid davidomid commented May 18, 2019

This fixes #1045 and resolves #696.

This pull request fixes ThrowExactly and ThrowExactlyAsync, when using AggregateExceptions. The documentation has also been updated to reflect the changes.

These two methods previously would not throw an exception if an AggregateException was thrown containing an instance of the expected exception type. These methods will now throw an exception, unless you're asserting that an AggregateException was thrown.

@davidomid
Copy link
Contributor Author

@dennisdoomen @jnyrup

I've updated the documentation and tested that the site still looks good locally.

In terms of the comment I made above about how I would like to reduce the amount of duplicated code, this actually doesn't seem entirely feasible at this point and appears to be a widespread issue in the solution, including the areas where I deleted old code.
An example is that it seems difficult to share common functionality easily between FunctionAssertions and AsyncFunctionAssertions, (i.e. the ThrowExactly method) as they don't use a common type. Perhaps in a future item we can look at strategies for refactoring this logic so we have to worry less about duplicate implementations of common methods?

In terms of this PR, do you have any other suggestions for other changes to be made at this stage, or are things at least good enough for this fix to be merged?

Thanks very much :)

@davidomid davidomid changed the title [WIP] Fix for issue #1045 (ThrowExactly and ThrowExactlyAsync not working with AggregateExceptions) Fix for issue #1045 (ThrowExactly and ThrowExactlyAsync not working with AggregateExceptions) May 25, 2019
@dennisdoomen
Copy link
Member

An example is that it seems difficult to share common functionality easily between FunctionAssertions and AsyncFunctionAssertions, (i.e. the ThrowExactly method) as they don't use a common type. P

Actually, this is exactly what I did in #1048.

@davidomid
Copy link
Contributor Author

Actually, this is exactly what I did in #1048.

Thanks, I'll check out what you did in that PR and try and refactor things in a similar way.

@dennisdoomen
Copy link
Member

Or rebase on mine ;-)

@davidomid davidomid changed the title Fix for issue #1045 (ThrowExactly and ThrowExactlyAsync not working with AggregateExceptions) Fix for issues #1045 and #696 (ThrowExactly and ThrowExactlyAsync not working with AggregateExceptions) May 27, 2019
@davidomid
Copy link
Contributor Author

Or rebase on mine ;-)

I gave rebasing a go and had a look over all the changes but it turns out they weren't really in line with what I needed to reduce the duplicate code between AsyncFunctionAssertions and ActionAssertions.

I took a different approach which you can see here #1054

@davidomid
Copy link
Contributor Author

Awaiting merge of #1054

@jnyrup jnyrup requested a review from dennisdoomen May 31, 2019 16:53
@davidomid
Copy link
Contributor Author

@dennisdoomen that duplicate code has now been removed, due to merging in the latest refactorings from master.

Please let me know if there's any other changes needed for this PR.

Thanks very much

@dennisdoomen dennisdoomen changed the title Fix for issues #1045 and #696 (ThrowExactly and ThrowExactlyAsync not working with AggregateExceptions) Fix for ThrowExactly and ThrowExactlyAsync not working with AggregateExceptions Jun 2, 2019
@jnyrup jnyrup merged commit 0474728 into fluentassertions:master Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants