Esempio n. 1
0
        public void ShouldThrowNotSupportedExceptionForOtherThanRequestInitializationContextTypeOfContexts()
        {
            HttpContextProvider provider = new HttpContextProvider();

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

            Assert.Throws <NotSupportedException>(action);
        }
Esempio n. 2
0
        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);
        }