2

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.

M.Hassan
  • 10,282
  • 5
  • 65
  • 84

2 Answers2

3

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

Dennis Doomen
  • 8,368
  • 1
  • 32
  • 44
  • Thanks @dennis Doomen for answer. Is there any change in the signature of the methods.? – M.Hassan Jan 09 '19 at 18:14
  • I also came yo conclusion that search replace was the simplest most efficient option. – Vidmantas Blazevicius Jan 09 '19 at 20:23
  • @VidmantasBlazevicius, i want to be sure that there is no change in the signature of the methods. Are you sure that the parameters of the methods are not changing? – M.Hassan Jan 09 '19 at 20:52
  • As you mentioned yourself, FA introduces quite a few breaking changes, most dominantly making sure that every API starts with `Should()`, But I've converted about 20K tests using search replace. Since I'm the author.... – Dennis Doomen Jan 10 '19 at 10:38
1

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

M.Hassan
  • 10,282
  • 5
  • 65
  • 84