How to run a unit test Asp.net Core WebAPI project (net452)?

I currently have an Asp.net Core Web.Api project.
It (only) targets the net452 infrastructure .
Question: How to make a unit test project asp, net core WebAPI (net452)?

I have already tried adding a classic .net testing project to my project, with a link to my main web.api project. For some reason, I cannot declare (reference) to any class inside my webapi project. From this, I came to the conclusion that I cannot use the classic unit testing project to test the main Asp.net project.

inside my project.json:

 "frameworks": {
   "net452": {}
   }
}

this is my solution:

solution

inside my test class:

[TestClass]
public class ActiveDirectoryClientProviderTests
{
    [TestMethod]
    public async Task Get_Should_Return_Client()
    {
        //var settings = new ActiveDirectorySettings();
        Ng2Aa_demo.Domain.Avatar.GetAvatarByUserHandler
    }
}
+4
2

xUnit NUnit, .Net.

, unit test: https://docs.microsoft.com/en-us/dotnet/articles/core/testing/unit-testing-with-dotnet-test

.Net, xUnit NUnit unit test.

json xUnit:

{
  "version": "1.0.0-*",
  "testRunner": "xunit",

  "dependencies": {
    "Microsoft.NETCore.App": {
      "type":"platform",
      "version": "1.0.0"
    },
    "xunit":"2.1.0",
    "dotnet-test-xunit": "1.0.0-rc2-192208-24",
    "PrimeService": {
      "target": "project"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        }
      },
      "imports": [
        "dotnet5.4",
        "portable-net451+win8"
      ]
    }
  }
}

+2
  • enter image description here

  • project.json 2 testRunner. Xunit!!

enter image description here

"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029"

unit test api xunit!

0

Source: https://habr.com/ru/post/1659953/


All Articles