public void ShouldThrowNotSupportedExceptionForOtherThanRequestInitializationContextTypeOfContexts()
    {
      HttpContextProvider provider = new HttpContextProvider();

      Assert.ThrowsDelegate action = () => provider.SetInitializationContext(new object());

      Assert.Throws<NotSupportedException>(action);
    }
    public void ShouldSetAndRestoreHttpContextFromInitializationContext()
    {
      HttpContext.Current = null;
      HttpContext httpContext = new HttpContext(new HttpRequest(string.Empty, "http://url", string.Empty), new HttpResponse(new StringWriter()));

      using (HttpContextProvider provider = new HttpContextProvider())
      {
        provider.SetInitializationContext(new RequestInitializationContext(new Request(), new Response()) { HttpContext = httpContext });

        Assert.Equal(httpContext, HttpContext.Current);
      }

      Assert.Null(HttpContext.Current);
    }