-
Notifications
You must be signed in to change notification settings - Fork 731
FluentAction for shorter syntax for exception assertions #1017
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
Conversation
Src/FluentAssertions/FluentAction.cs
Outdated
| /// Contains static methods to help with exception assertions on actions. | ||
| /// </summary> | ||
| [DebuggerNonUserCode] | ||
| public static class FluentAction |
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 think naming this class FluentActions would be better, since it is just a static container with static methods.
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.
Fair enough. Fixed: 0459a63
docs/_pages/documentation.md
Outdated
| act.Should().NotThrowAfter(2.Seconds(), 100.Milliseconds()); | ||
| ``` | ||
|
|
||
| If you prefer single-statement assertions, consider using the `FluentAction` static class, which has `Invoking`, `Awaiting`, and `Enumerating` methods: |
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.
👍
Src/FluentAssertions/FluentAction.cs
Outdated
| public static class FluentAction | ||
| { | ||
| /// <summary> | ||
| /// Invokes the specified action so that you can chain it with ShouldThrow, etc. |
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.
Should().Throw()?
ShouldThrow() is pre-5.0.0 notation.
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.
Fixed: 03d3877
| /// Invokes the specified action so that you can chain it with ShouldThrow, etc. | ||
| /// </summary> | ||
| [Pure] | ||
| public static Func<T> Invoking<T>(Func<T> func) => func; |
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.
@dennisdoomen If we decide on the name Invoking for Fun<T> here, then #872 should also be named Invoking for consistency.
docs/_pages/documentation.md
Outdated
| If you prefer single-statement assertions, consider using the `FluentAction` static class, which has `Invoking`, `Awaiting`, and `Enumerating` methods: | ||
|
|
||
| ```csharp | ||
| FluentAction.Invoking(() => MyClass.Create(null)).Should().Throw<ArgumentNullException(); |
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.
typo: Missing > after ArgumentNullException.
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.
Good catch! Fixed: 0459a63
docs/_pages/documentation.md
Outdated
|
|
||
| ... | ||
|
|
||
| Invoking(() => MyClass.Create(null)).Should().Throw<ArgumentNullException(); |
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.
typo: Missing > after ArgumentNullException.
|
I also forgot to add the unit tests to the shared project. 😬 Fixed: 7a647b3 |
|
Thanks for the contribution @ejball. |
For issue #1015.