title: Testing WebControl, that is tightly coupled with System.Web.UI.Page
body: <p>I'm working with legacy code, migrating to new architecture. I wanted to create tests for one of the classes, that I'm currently working on. It inherits WebControl (with few classes in between) and references to Page.Request.RawUrl in CreateChildControls method and in few other places, which throws exception during test execution: &quot;System.Web.HttpException : Request is not available in this contex&quot;. I tried to mock Page object with moq, but since Request property is not virtual it also gives an exception. I also tried to use reflection, but it also didn't work for me, since Request property has only public getter, but I'm not fluent with reflection, so maybe I'm missing something here.</p>
  <p>Is there any way to test such class? Or should I just give up with DRY and copy this class to be able to modify it and then test it? I can't modify this class directly, since it's in referenced library and used by other projects.</p>