Skip to content

Instantly share code, notes, and snippets.

@dupdob
Last active June 21, 2018 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dupdob/e53c1e6e0291688088687c921bee751c to your computer and use it in GitHub Desktop.
Save dupdob/e53c1e6e0291688088687c921bee751c to your computer and use it in GitHub Desktop.
Extending NFluent to support FluentAssertions/Shouldly like syntax
namespace ExtraFluent
{
public static class ExtraFluent
{
/// <summary>
/// Provides entry point to NFluent checks using extension syntax
/// </summary>
/// <param name="sut">the system under test</param>
/// <typeparam name="T">Type of the system under test.</typeparam>
/// <returns>an Instance of <see cref="ICheck{T}"/></returns>
// voir GH #253
public static ICheck<T> Verifies<T>(this T sut)
{
return Check.That(sut);
}
}
}
@dupdob
Copy link
Author

dupdob commented Jun 21, 2018

If you prefer FluentAssertions/Shouldly like syntax for your assertion instead of the the glorious Check.That entry point, just add this class to your tests.
You can then write your assertions like this

    int sut = 2;
    sut.Verifies().IsEqualTo(2);
    // collections
    new[] {1, 2, 3}.Verifies().IsEquivalentTo(3, 2, 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment