???????????????????????????Page_Load??????????????????????????????????“test u”??????????????Response.Write???????????????????????????????????????????????????????????????紫????????????????Response.Write?????????????????????????к???????????????????????????????

????1??????????????Page_Load???????????????????Response.Write???????

????2??Response.Write??Page_Load????е???????????????????????????????????

?????????Response.Write??????TextWriter??????????????????TextWriter?????????StringWriter??

???????????????????????????????????д???????????????????????????????????????

Public void UploadFile()
{
  Var file = _request.Files[0];
  If(file.contentLength==0 || file.ContentLength > 5 * 1024 * 1024)
  {
throw new ArgumentException();
  }
  File.SaveAs(file.FileName);
}

?????????????????????????????????????????

[TestMethod]
public void ThrowExceptionIfFilelengthInvalid()
{
  FakeRequest = new Mock();
  FakeFiles = new Mock();
  FakeFile = new Mock();

  FakeFile.SetupGet(x=> x.ContentLength).Returns(6 * 1024 * 1024);
  FakeFiles.SetupGet( x=> x[0]).Returns(FakeFile.Object);
  FakeRequest.SetupGet( x=>x.Files).Returns(FakeFiles.Object);

  this._request = FakeRequest.Object;

  try
  {
this.UploadFile();
Assert.Fail();
  }
  catch(ArugmentOutOfRangeException)
  {
  }
}

?????????????http://www.cnblogs.com/luminji/archive/2012/11/30/2796032.html