I have a unit test project which references FluentAssertions, I get errors when I update to version 3

StackOverflow https://stackoverflow.com/questions/23371910

  •  12-07-2023
  •  | 
  •  

Question

I have a .net 4.0 test project which is throwing a method not found exceptions for the Should() extension method.

Then I noticed it also was throwing exceptions for an int type as well.

Does anybody know why FluentAssertions V3 is behaving this way?

For now I am going back to my version 2.2.

For reference, this is the FluentAssersions project website https://github.com/dennisdoomen/fluentassertions/releases

here's the code sample: enter image description here

var actualItems = new List<string> { "" };
actualItems.All(i => i == "X").Should().BeTrue("All items should be X") ;

here's an exceptions:

Error   237 'bool' does not contain a definition for 'Should' 
and no extension method 'Should' accepting a first argument of type 'bool' 
could be found (are you missing a using directive or an assembly reference?)
C:\pathtoproject\Tests.cs
Was it helpful?

Solution

That's because v3.0 requires .NET 4.0.3 for your test projects. This is the earliest version supported by the Portable Class Libraries. It's a bit confusing, but if you already installed .NET 4.5, you are already using 4.0.3. I have updated the release notes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top