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

1

7

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
Claudy answered 29/4, 2014 at 17:55 Comment(1)
Can you post the line that throws the exception?Calamity
L
9

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.

Lallage answered 29/4, 2014 at 18:19 Comment(6)
I'm running VS 2013 on Windows 8.1, so I have .NET 4.5, but I still get this problem. Also, where do I find the release notes for v3.0? My test project targets .NET 4, which results in the following warning when building: Warning 7 The primary reference "FluentAssertions" could not be resolved because it was built against the ".NETFramework,Version=v4.0.3" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0". ESeaMatic.Common.TestingJeffjeffcoat
Your unit test project should be targeting 4.0.3. The release notes are here: github.com/dennisdoomen/fluentassertions/releases/tag/…Lallage
I got it to work: I had to install the .NET Framework 4.0.3 Targeting Pack to get the 4.0.3 target. BTW, I get a 404 when I click the release notes link.Jeffjeffcoat
If I use that link, I only get the release notes for 2.2.Jeffjeffcoat
Aouch, now I see the problem. The release notes were still in draft. Sorry for that.Lallage
Last weekend we've release v3.1 which resolves the above problem. We now support plain old .NET 4.0 again.Lallage

© 2022 - 2024 — McMap. All rights reserved.