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
BraveNewMath
  • 8,090
  • 5
  • 46
  • 51

1 Answers1

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.

Dennis Doomen
  • 8,368
  • 1
  • 32
  • 44
  • 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.Testing``` – dabide May 07 '14 at 07:30
  • Your unit test project should be targeting 4.0.3. The release notes are here: https://github.com/dennisdoomen/fluentassertions/releases/tag/untagged-d0fd6124f783da067078 – Dennis Doomen May 07 '14 at 07:56
  • I got it to work: I had to install the [.NET Framework 4.0.3 Targeting Pack](http://www.microsoft.com/en-us/download/details.aspx?id=29052) to get the 4.0.3 target. BTW, I get a 404 when I click the release notes link. – dabide May 07 '14 at 09:37
  • If I use that link, I only get the release notes for 2.2. – dabide May 07 '14 at 12:02
  • 1
    Aouch, now I see the problem. The release notes were still in draft. Sorry for that. – Dennis Doomen May 07 '14 at 12:05
  • 2
    Last weekend we've release v3.1 which resolves the above problem. We now support plain old .NET 4.0 again. – Dennis Doomen Jul 31 '14 at 18:24