在完整的 .NET 框架上测试 Asp.Net 核心

Testing Asp.Net Core on full .NET framework

我想对面向完整 .net 框架的 asp.net 核心项目进行单元测试。我尝试使用 "normal" 单元测试项目模板和 this blog post 中概述的 .net 核心项目,但两次尝试都失败了,因为在任何一个测试项目中都无法引用我的 Web 项目的程序集。

有没有办法在完整框架上对 asp.net 核心应用程序进行单元测试?

在同一博客的评论部分找到了解决方案 post。由于我不能直接link,所以引用如下:

BillyboyD

In case anyone needs to do something similar, I have managed to set this up so I can test my controllers in an ASP.NET Core project that targets the .NET Framework 4.6.1 and also references class libraries that are standard .NET, not .NET core (we will have this hybrid situation for some time!). I am using VS2015 update 3 and .NET Core 1.0. My project.json is:

{
    "version": "1.0.0-*",
    "testRunner": "mstest",
    "dependencies": {
        "dotnet-test-mstest": "1.0.1-preview",
        "MSTest.TestFramework": "1.0.0-preview",
        "MyASP.NetCoreProject": "1.0.0-*"
    },
    "frameworks": {
        "net461": {
            "dependencies": {
                "MyClassLibrary": {
                    "target": "project"
                }
            }
        }
    }
}