Skip to content

Conversation

@ejball
Copy link
Contributor

@ejball ejball commented Mar 31, 2019

For issue #1015.

/// Contains static methods to help with exception assertions on actions.
/// </summary>
[DebuggerNonUserCode]
public static class FluentAction
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough. Fixed: 0459a63

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

Choose a reason for hiding this comment

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

👍

public static class FluentAction
{
/// <summary>
/// Invokes the specified action so that you can chain it with ShouldThrow, etc.
Copy link
Member

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.

Copy link
Contributor Author

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

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.

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

Choose a reason for hiding this comment

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

typo: Missing > after ArgumentNullException.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Fixed: 0459a63


...

Invoking(() => MyClass.Create(null)).Should().Throw<ArgumentNullException();
Copy link
Member

Choose a reason for hiding this comment

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

typo: Missing > after ArgumentNullException.

@ejball
Copy link
Contributor Author

ejball commented Mar 31, 2019

I also forgot to add the unit tests to the shared project. 😬 Fixed: 7a647b3

@jnyrup jnyrup merged commit 311aa0a into fluentassertions:master Mar 31, 2019
@jnyrup
Copy link
Member

jnyrup commented Mar 31, 2019

Thanks for the contribution @ejball.
Lookout for your name in the next release notes.

@ejball ejball deleted the fluent-action branch March 31, 2019 22:21
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.

3 participants