小编Nin*_*ore的帖子

我们可以在asp.net中对global.asax进行单元测试吗?

我在进行单元测试.我不知道如何在asp.net中对global.asax进行单元测试.asp.net中的global.asax是否属于单元测试覆盖范围?还有应用程序安装程序类,其中包含系统变量.我应该测试一下吗?

.net c# nunit rhino-mocks global-asax

8
推荐指数
2
解决办法
2570
查看次数

Response.StatusCode 在 nunit 测试中为 null

我正在编写单元测试用例。我正在尝试为此方法编写单元测试,但显示错误。如何在 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)

c# asp.net-mvc nunit response asp.net-mvc-3

4
推荐指数
1
解决办法
2434
查看次数

如何在c#中对这个方法进行单元测试?

我正在学习单元测试.如何使用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)

c# nunit asp.net-mvc-3

4
推荐指数
1
解决办法
2541
查看次数

如何单元测试此方法的catch块?

我正在学习单元测试.如何使用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)

c# error-handling nunit rhino-mocks asp.net-mvc-3

2
推荐指数
1
解决办法
2429
查看次数