我读过许多关于mvc中的嘲笑的文章和博客.其中许多都很有帮助,但我仍然有一些问题:
发布于 2011-12-09 09:58:33
您可以使用诸如MVC-比较法TestHelper之类的工具
站点中的此示例演示如何测试在会话中存储已发布表单值的操作。
[Test]
public void AddSessionStarShouldSaveFormToSession()
{
TestControllerBuilder builder = new TestControllerBuilder();
StarsController controller = new StarsController();
builder.InitializeController(controller);
//note that this is assigned before the controller action. This simulates the server filling out the form data from the request
builder.Form["NewStarName"] = "alpha c";
//this assumes that AddSessionStar takes the form data and adds it to the session
controller.AddSessionStar();
Assert.AreEqual("alpha c", controller.HttpContext.Session["NewStarName"]);
}https://stackoverflow.com/questions/8443746
复制相似问题