I recently installed Visual Studio 2015 and started a project with a web site and a asp class library which will contain the unit tests for the web site. I usually use Moq for mocking but I am no stranger to try a different mocking framework. The problem I am having is that I added Moq as a reference to the unit test project and started using it. Everything seems fine at first until I tried to compile.
When I compiled I got an error message saying:
ASP.NET Core 5.0 error CS0246: The type or namespace name 'Moq' could not be found (are you missing a using directive or an assembly reference?)
I noticed that I could switch between ASP.NET 5.0 and ASP.NET Core 5.0 in the code view and when selecting ASP.NET Core 5.0 I get errors but no when selecting ASP.NET 5.0. I tried searching for an answer but I did not have any luck.
Is the problem that Moq does not work with vnext and I should use a different framework (if so which works?) or can I solve this somehow?
My project.json:
{
"version": "1.0.0-*",
"dependencies": {
"Web": "1.0.0-*",
"Xunit.KRunner": "1.0.0-beta1",
"xunit": "2.0.0-beta5-build2785",
"Moq": "4.2.1409.1722"
},
"frameworks": {
"aspnet50": {
"dependencies": {
}
},
"aspnetcore50": {
"dependencies": {
}
}
},
"commands": {
"test": "Xunit.KRunner"
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…