Skip to content

Instantly share code, notes, and snippets.

@boekabart
Created January 17, 2018 23:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boekabart/8d4bc968685ef78dda2d8ddd97086f0d to your computer and use it in GitHub Desktop.
Save boekabart/8d4bc968685ef78dda2d8ddd97086f0d to your computer and use it in GitHub Desktop.
Regex find/replace pairs to migrate many common xUnit Assertions to FluentAssertions syntax
Assert\.NotNull\((.*)\);
$1.Should().NotBeNull();
Assert\.Null\((.*)\);
$1.Should().BeNull();
Assert\.Equal\(\s*(\d+)\s*,\s*(.*)\.Length\);
$2.Should().HaveCount($1);
Assert\.Equal\(\s*([^,]+)\s*,\s*(.*)\s*\);
$2.Should().Be($1);
Assert\.True\((.+)\.Any\((.*)\)\);
$1.Should().Contain($2);
Assert\.True\((.+)\);
$1.Should().BeTrue();
Assert\.False\((.+)\);
$1.Should().BeFalse();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment