[英]Dot Net Core and Azure Storage: Could not load file or assembly System, Version=4.0.0.0
[英]Getting Could not load file or assembly 'System.Core, Version=4.0.0.0..' While doing unit testing in asp.net core with moq
我正在进行一个非常简单的单元测试。 当我运行测试时,我得到异常无法加载文件或程序集'无法加载文件或程序集'System.Core,Version = 4.0.0.0 ..'在我添加“Microsoft.NETCore.Portable.Compatibility”后出现此错误“:”1.0.1“在我的Project.json文件中。 但它是必需的,否则我不能在单元测试中使用lambda Expression。
我的单元测试中没有编译时错误。我确定我的测试没有任何问题,因为project.json文件丢失了一些东西。 以下是我的考试。
Mock<RegistrationManager> manager = new Mock<RegistrationManager>();
Mock<RegistrationModel> model = new Mock<RegistrationModel>();
var value = manager.Setup(a => a.GetDataFieldValuesForModel(model.Object, CommandType.next)).ReturnsAsync(new RegistrationModel { hasError = false, FormId="123",LeadId="345" });
{
"version": "0.1.0-*",
"dependencies": {
"Moq": "4.5.22",
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"IntegraPay.Domain": {
"version": "1.0.0-*",
"target": "project"
},
"Integrapay.RegistrationApplication": {
"version": "",
"target": "project"
},
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"net451"
],
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
},
"testRunner": "xunit"
}
有同样的问题。
解决了几个变化:
我的最终project.json看起来像:
{
"version": "1.0.0-*",
"dependencies": {
"NUnit": "3.5.0",
"dotnet-test-nunit": "3.4.0-beta-2",
"MyTestingProject": "1.0.0-*",
"Moq.netcore": "4.4.0-beta8",
"System.Diagnostics.TraceSource": "4.0.0"
},
"testRunner": "nunit",
"frameworks": {
"netcoreapp1.0": {
"imports": [
"netcoreapp1.0",
"dnxcore50"
],
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.