简体   繁体   中英

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

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.

我确实使用了Visual Studio提供的RegEx搜索和替换来实现此目的。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM