使用MvcIntegrationTestingFramework模拟表单数据中的文件上载

时间:2012-08-01 12:35:04

标签: asp.net-mvc form-data

我正在使用Steve Sanderson的MvcIntegrationTestingFramework并尝试模拟上传动作的帖子。第二个参数是一个对象,然后将其转换为要发布的表单数据的名称值对。

我的测试代码是:

    [Test]
    [Category("integration")]
    public void UploadRunsCorrectlyWhenConfiguredFromApplicationStart()
    {
        var appHost = AppHost.Simulate("ingester");
        appHost.Start(session =>
                          {
                              var result = session.Post("upload/upload", 
                                           new
                                           {
                                             id = Guid.NewGuid().ToString(),
                                             file = ***Help here ***
                                            });
                              Assert.That(result.Response.StatusCode == 202);
                          } );
    }

行动是:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Upload(string id, HttpPostedFileBase file)
    {
         //Need file to not be null here
    }

我的问题是我应该在 帮助 中添加哪些文件才能显示为空?

谢谢:)

0 个答案:

没有答案