The target framework of the sample from GitHub is netcoreapp 2.0
I'm trying to build an app using ASP.NET Core 2.1 but due the lack of documentation I'm now considering use 2.0 instead.
Is there an example using ASP.NET Core 2.1 for Unit Testing?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
There shouldn't be any difference in unit testing an ASP.NET Core application built targeting 2.0 vs. 2.1. Are you seeing a specific issue that you attribute to the minor version mismatch?
This is the error that I get:
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'IActionResult' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. WebApplication1.Test.UnitTest C:\Users\Diego\source\repos\aspnet2.1\Docs\aspnetcore\mvc\controllers\testing\sample\WebApplication1\WebApplication1.Test.UnitTest\UnitTest1.cs 17 Active
I see in _Quick actions and Refactorings..._ the following suggestion:
Add Reference to 'Microsoft.AspNetCore.Mvc.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
I clic on the _light bulb_ icon but the error continue.
Do I have to edit the _.csproj_ file or what can solve this ?
P.S. I leave here the project sample that I am using https://github.com/YeyoCoder/aspnet2.1/tree/master/Docs/aspnetcore/mvc/controllers/testing/sample/WebApplication1
I use the _NuGet Package Manager_ and install
That fix the error and now the test pass !
Most helpful comment
I use the _NuGet Package Manager_ and install
That fix the error and now the test pass !