我试图在我的系统中对一个方法进行单元测试
MyViewModel
从
BaseViewModel
这个
BaseViewModel
有这样的方法吗
protected bool DoSomething()
{
if (something)
{
ServiceLocator.Current.GetInstance ...; //ERROR
return true;
}
else
{
return false;
}
}
DoSomething
几乎在每个视图模型中都被称为。该应用程序按预期工作,但我正在尝试单元测试(NUnit)和调用的每个方法
剂量
就是单元测试失败
我得到的错误是
error CS0119: 'ServiceLocator' is a type, which is not valid in the given context
这个
ServiceLocator
是从哪里来的
Autofac.CommonServiceLocator