title: File upload unit testing
body: <p>I have a Controller for creating template. This controller accept template model as Parameter.The controller contains the code for file upload. I don't understand how to unit test this code...</p>
  
  <p>This is my model:</p>
  
  <pre><code>public class Template
  {
     public string TemplateName {get; set;}
     public string Description {get; set;}
     public string FileName {get; set;}
  } 
  </code></pre>
  
  <p>This is my controller</p>
  
  <pre><code>public ActionResult Create(Template template)
  {
     if (ModelState.IsValid)
              {
                  var file = Request.Files["FileName"];
                  template.FileName = template.TemplateName;
  
                  long TemplateId = _templateService.Create(template);
                  string path = Server.MapPath("~/Templates/Archieve/" + TemplateId);
                  Directory.CreateDirectory(path);
                  string archievePath = Server.MapPath("~/Templates/Archieve/" + TemplateId + "/" + "Template" + TemplateId + ".zip");
  
                  file.SaveAs(archievePath);
                  using (ZipFile zip = ZipFile.Read(archievePath))
                  {
                      zip.ExtractAll(Server.MapPath("~/Templates/" + TemplateId), ExtractExistingFileAction.DoNotOverwrite);
  
                  }
  
                  return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>This is my unit test:</p>
  
  <pre><code>public void Create_Template()
  {
       //Arrange
       var template = new Template()
                  {
                      Description = "Description",
                      FileName = null,
                      TemplateName = "name"
                  };
  
                  //Act
                  var result = controller.Create(template) as RedirectToRouteResult;
  
                  //Assert
                  Assert.AreEqual("index", result.RouteValues["action"]);
  }
  </code></pre>
  
  <p>How to unit test Request.Files[FileName] and Server.MapPath</p>