C# 单元测试 如何测试上下文:例如Excel导出代码:
......
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls");
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.Write(strb);
HttpContext.Current.Response.End();
如何测试代码
可以使用mock类的框架,去产生你的测试上下文