如果我有一个类,它具有通过属性注入解决的依赖项,那么是否可以使用Moq模拟该属性的行为?
例如:
例如:
public class SomeClass
{
//empty constructor
public SomeClass() {}
//dependency
public IUsefuleService Service {get;set;}
public bool IsThisPossible(Object someObject)
{
//do some stuff
//I want to mock Service and the result of GetSomethingGood
var result = Service.GetSomethingGood(someObject);
}
}
因此,SomeClass正在接受测试,我试图弄清楚是否可以使用Moq模拟IUsefulService的行为,以便在测试IsThisPossible时,使用服务的那一行将使用模拟...