I am having a very simple unit test. when I run the test I get the exception Could not load file or assembly 'Could not load file or assembly 'System.Core, Version=4.0.0.0..' This error started appearing after I added "Microsoft.NETCore.Portable.Compatibility": "1.0.1" in my Project.json file. But it is required or else I cannot use lambda Expression in unit testing.
There is no compile time error in my unit test.I am sure there is nothing wrong with my test it is the project.json file missing something . below is my test.
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"
}
Had the same issue.
Solved it by several changes:
My final project.json looks like: