I am currently building an aspnet core 3.0 web api with a core 3.0 test project.
In my controller Method I use the generic version of ActionResult as return value.
If I now try to write a test containing this particular class, ncrunch tells me the following:
Code:
CSC (0, 0): Assembly "RecipeBuilderApplicationApi" mit Identität "RecipeBuilderApplicationApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" verwendet "Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" mit einer höheren Version als die referenzierte Assembly "Microsoft.AspNetCore.Mvc.Core" mit Identität "Microsoft.AspNetCore.Mvc.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
Controller\ToolControllerTest.cs (34, 13): Typ "ActionResult" ist nicht generisch und kann daher nicht mit Typargumenten verwendet werden.
Controller\ToolControllerTest.cs (34, 64): Assembly "RecipeBuilderApplicationApi" mit Identität "RecipeBuilderApplicationApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" verwendet "Microsoft.AspNetCore.Mvc.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" mit einer höheren Version als die referenzierte Assembly "Microsoft.AspNetCore.Mvc.Core" mit Identität "Microsoft.AspNetCore.Mvc.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60".
Seems like ncrunch is using version 1.0.3.0 from Mvc.Core whilst I use version 3.0.0.0 therefore not finding the generic version of ActionResult.
Ncrunch however seems fine when building the webapi project. It just refuses to build the test project.
Controller:
Code:
public async Task<ActionResult<IList<ToolDto>>> GetRelevantTools() {
Test:
Code:
ActionResult<IList<ToolDto>> relevantTools = await toolController.GetRelevantTools();
What do I need to do to tell ncrunch to use version 3.0.0.0 in the test project?
Just created a small webApi/Nunit test project from default vs2019 templates and I am not able to get ncrunch to build the test project:
Code:
NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
UnitTest1.cs (2, 17): Der Typ- oder Namespacename "AspNetCore" ist im Namespace "Microsoft" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)
UnitTest1.cs (3, 28): Der Typ- oder Namespacename "Logging" ist im Namespace "Microsoft.Extensions" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)
It tells type or namespace AspNetCore and Logging is missing. Strange thing is that it runs just fine in Resharper testrunner.
Same applies for the main problem. It runs just fine within resharper.