DynamicsValue / fake-xrm-easy

FakeXrmEasy: The Test Automation Framework for the Power Platform / Dataverse
https://dynamicsvalue.github.io/fake-xrm-easy-docs/why/
Other
26 stars 12 forks source link

FakeXrmEasy breaks when using FakeItEasy 7 #37

Closed LarsBauer closed 2 years ago

LarsBauer commented 2 years ago

Hi, just wanted to make you aware that the Middleware setup fails with the following exception when using FakeItEasy 7.

System.EntryPointNotFoundException
Entry point was not found.
   at FakeItEasy.Configuration.ICallbackConfiguration`1.Invokes(Action`1 action)
   at FakeItEasy.CallbackConfigurationExtensions.Invokes[TInterface,T1](ICallbackConfiguration`1 configuration, Action`1 actionToInvoke) in C:\projects\fakeiteasy\src\FakeItEasy\CallbackConfigurationExtensions.StronglyTyped.cs:line 31
   at FakeXrmEasy.Middleware.Crud.MiddlewareBuilderCrudExtensions.AddFakeUpdate(IXrmFakedContext context, IOrganizationService service)
   at FakeXrmEasy.Middleware.Crud.MiddlewareBuilderCrudExtensions.<>c.<AddCrud>b__1_0(IXrmFakedContext context)
   at FakeXrmEasy.Middleware.MiddlewareBuilder.Add(Action`1 addToContextAction)
   at FakeXrmEasy.Middleware.Crud.MiddlewareBuilderCrudExtensions.AddCrud(IMiddlewareBuilder builder)

In the dependencies of your package the range is listed as FakeItEasy ≥ 6.0.0 which basically allows FakeItEasy 7. Maybe you should update this range to prevent people from having the same troubles as myself.

Let me know if you need any more details. Thanks in advance!

jordimontana82 commented 2 years ago

Thanks for reporting this @LarsBauer

Yeah makes sense.

jordimontana82 commented 2 years ago

Added it for the next release

jordimontana82 commented 2 years ago

This fix made it to both 2.1.1 and 3.1.1 versions.

https://dynamicsvalue.github.io/fake-xrm-easy-docs/releases/3x/3.1.1/

https://dynamicsvalue.github.io/fake-xrm-easy-docs/releases/2x/2.1.1/

@LarsBauer can you try again ?

LarsBauer commented 2 years ago

Thanks for the update. I think the dependency range is updated correctly according to the docs. Nevertheless I am still able to upgrade FakeItEasy to version 7.0.0 or higher without NuGet complaining. I am not sure if this is the normal behavior...

jordimontana82 commented 2 years ago

You're welcome.

Could you please post the PackageReferences you have in your .csproj, if possible?

LarsBauer commented 2 years ago

Sure, here are my package references:

    <ItemGroup>
        <PackageReference Include="FakeItEasy" Version="6.2.1" />
        <PackageReference Include="FakeXrmEasy.Core.v9" Version="3.1.1" />
        <PackageReference Include="FakeXrmEasy.Messages.v9" Version="3.1.1" />
        <PackageReference Include="FluentAssertions" Version="6.7.0" />
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
        <PackageReference Include="xunit" Version="2.4.1" />
        <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="coverlet.collector" Version="3.1.2">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
    </ItemGroup>
jordimontana82 commented 2 years ago

Could you try removing this reference in your .csproj to see if it still allows the upgrade? (the FakeItEasy dependency will be installed via FXE anyway, so just to check....)

<PackageReference Include="FakeItEasy" Version="6.2.1" />
LarsBauer commented 2 years ago

Doesn't make any difference. I removed the direct package reference for FakeItEasy but I was able to install it after afterwards in version 7.0.0 or higher. I tried to downgrade to version 5.0.0 but there NuGet complained. So I guess maybe there is something wrong with the upper range?

jordimontana82 commented 2 years ago

The upper range format should be fine according to the docs and nuget package ranges. I'll setup a sample repo myself and try to reproduce it.

jordimontana82 commented 2 years ago

What target framework are you using? netcoreapp3.1?

LarsBauer commented 2 years ago

What target framework are you using? netcoreapp3.1?

net6.0

jordimontana82 commented 2 years ago

Hi @LarsBauer

I did some digging on this and dotnet restore does throw warnings and it looks like it is by design in the tooling. The easiest would be to just not include the FakeItEasy dependency explicitly in your test project and so the package ranges in FXE will be honored.

imagen

More info about NU1608 in the wiki:

https://github.com/NuGet/Home/wiki/Restore-errors-and-warnings

Here's a sample repo I setup myself if you want to reproduce it:

https://github.com/DynamicsValue/fxe-samples/tree/main/net60/issue_37/TestProject

LarsBauer commented 2 years ago

Alright, so it seems to be by design. Thanks for investigating!

jordimontana82 commented 2 years ago

No worries, I've also updated the ToC in the docs site, you'll find more info there....

https://dynamicsvalue.github.io/fake-xrm-easy-docs/quickstart/