Migrating xunit project with FluentAssertions API 4.x syntax to run using FluentAssertions v5.x version

Viewed 81

I know that there is a breaking change from FluentAssertions v4.x to v5.x in Redefining equivalency So, I should modify:

        ShouldBeEquivalenTo ()

to

         Should().BeEquivalentTo()

and a lot more has changed.

I have xunit test project target net45 and start to migrate to multi-target netcoreapp2.1 and net45.(FluentAssertions v4.x isn't supporting netcoreapp2.x)

The project has many test cases that use old syntax of 4.x and I want to minimize the changes in the test project and avoid(if i can) modifying to the new syntax.

My options are:

First: I should modify by hand the test cases to support the new syntax of v5.x

Second: you may suggest be an alternative.

Can you advice me to the best path to go.

2 Answers

I literally used the RegEx search-and-replace that Visual Studio offers to make this happen.

This answer is based on the answer of @Dennis Doomen

I used Find/Replace Regex in VS2017:

   Find:  Should(\w+)
   Replace: Should().$1

This regex replace expressions:

ShouldBeEquivalentTo, ShouldAllBeEquivalentTo, ShouldThrow and ShouldNotThrow

Related