【发布时间】:2017-02-09 14:48:59
【问题描述】:
从单元测试和依赖注入的角度来看,辅助方法通常采用的规范是什么?
这是我的示例情况:
public class GoodiesController : Controller
{
private IMyContext _context;
public GoodiesController(IMyContext context)
{
_context = context
}
public async Task<IAction> GetThoseGoodies()
{
if(YouLikeThemThisWay(Request.Path))
{
var result = await _context.GoGetThemThisWay()
} else { }
}
我的问题是我最好将YouLikeThemThisWay(string path) 作为某个类中的静态助手还是作为私有实例方法?假设我可能有几个 YouLikeThemThisWay 之类的?
【问题讨论】:
标签: c# unit-testing dependency-injection