【发布时间】:2017-03-06 09:53:32
【问题描述】:
我有一个使用自定义 ExceptionHandler 来处理所有异常的 WebAPI。我如何对这个CustomExceptionHandler 进行单元测试。任何线索都会有所帮助
public class CustomExceptionHandler : ExceptionHandler
{
public override void Handle(ExceptionHandlerContext context)
{
try
{
context.Result = new ResponseMessageResult(context.Request.CreateResponse(HttpStatusCode.InternalServerError, context.Exception));
}
catch (Exception)
{
base.Handle(context);
}
}
public override bool ShouldHandle(ExceptionHandlerContext context)
{
return true;
}
}
【问题讨论】:
标签: c# unit-testing asp.net-web-api2 nunit moq