????BS???е?UI????????????????????????????Request?????????Response??????WebForm???MVC????????????Response??Request??HTTP???????????н???????????????????WebForm??????????Response??????????????????????

public sealed class HttpResponse

???????????????sealed?????仰??????????????????μ??Code-Behind?????????????????????????

protected void Page_Load(object sender?? EvengArgs e)
{
  this.Response.Write("test u");
}

????????FCL????????????HttpResponseWrapper??????????????????????д?????????????????????????μ???????????????????

protected HttpResponseBase _response;

protected override void OnPreLoad(EventArgs e)
{
  base.OnPreLoad(e);
  _response = new HttpResponseWrapper(this.Response);
}

protected void Page_Load(object sender?? EvengArgs e)
{
  _response.Write("test u");
}

???????????????????????й???????????????????????????

????1???????this.Response???????????????HttpResponseBase??

????2????Σ?????Page_Load??????????????????????????????

?????????????_response???????????????????????????????????????????????webform????????????????????У?this.Response????????????????????????????з????OnPreLoad?С?

??????????????????????д????????????Page_Load??protected?????ò????????????????????public???????ò????????????????棬??????????????

[TestClass]
public class _DefaultTest: _Default        ////?????????????????Default.aspx.cs?????
{
  public Mock FakeResponse;

  [TestMethod]
  public void LoadOk()
  {
FakeResponse = new Mock();

StringWriter sw = new StringWriter();
FakeResponse.SetupGet(x=>x.OutPut).Returns(sw);
this._response = FakeResponse.Object;

FakeResponse.Setup(x=>x.Write(It.IsAny())).CallBack
{
  sw.Write(x);
  sw.Flush();
}

this.Page_Load(null??null);
Assert.AreEqual(
  “test u”??
  (FakeResponse.Object.Output as StringWriter).ToString();
  }
}