我在进行单元测试.我不知道如何在asp.net中对global.asax进行单元测试.asp.net中的global.asax是否属于单元测试覆盖范围?还有应用程序安装程序类,其中包含系统变量.我应该测试一下吗?
我正在编写单元测试用例。我正在尝试为此方法编写单元测试,但显示错误。如何在 mvc3 框架和犀牛模拟中对这个方法进行单元测试。
public ActionResult UnderConstruction()
{
Response.StatusCode = (int)HttpStatusCode.TemporaryRedirect;
ErrorModel model = new ErrorModel()
{
ErrorMessage = "This page is still under construction; please check back later.",
Title = "Under Construction"
};
return View("Error", model);
}
Run Code Online (Sandbox Code Playgroud) 我正在学习单元测试.如何使用nunit和rhino mock对这个方法进行单元测试?
public ActionResult PrintCSV(Byte[] bytes, string fileName)
{
var file = File(bytes, "application/vnd.ms-excel");
var cd = new System.Net.Mime.ContentDisposition()
{
CreationDate = DateTime.Now,
FileName = fileName,
Inline = false
};
Response.AppendHeader("Content-Disposition", cd.ToString());
return file;
}
Run Code Online (Sandbox Code Playgroud) 我正在学习单元测试.如何使用NUnit和Rhino Mock对此方法进行单元测试?好吧,我已经测试了try块,并希望测试catch块代码覆盖率.
[HttpPost]
public ActionResult AppraisalOrderIsAcceptedByEmployee(int appraisalOrderId)
{
try
{
this.appraisalOrderService.SubmitAppraisalOrder(appraisalOrderId);
}
catch (MessageLoneException ex)
{
// Display validation errors
PersistErrors(ex);
// Remains on the same view
return RedirectToAction("VerifyOrderDetails", new { id = appraisalOrderId });
}
return GetLoginRedirectCurrentUser();
}
Run Code Online (Sandbox Code Playgroud)