【发布时间】:2016-12-30 10:16:37
【问题描述】:
如果我在该类中使用扩展方法,如何将具体类替换为其接口以进行单元测试?
我有一个方法:
[HttpGet]
[Route("/yoyo/{yoyoId:int}/accounts")]
public ResponseYoyoEnvelope GetAccountsByYoyoId([FromBody] RequestYoyoEnvelope requestYoyoEnvelope, int yoyoId)
{
var responseYoyoEnvelope = requestYoyoEnvelope.ToResponseYoyoEnvelope();
// get our list of accounts
// responseEnvelope.Data = //list of accounts
return responseYoyoEnvelope;
}
我想更换:
RequestYoyoEnvelope requestYoyoEnvelope
带有抽象:
IRequestYoyoEnvelope requestYoyoEnvelope
但是,ToResponseYoyoEnvelope 是一种扩展方法。
如果我在该类中使用扩展方法,如何将具体类替换为其接口以进行单元测试?
【问题讨论】:
标签: c# visual-studio unit-testing nunit