public void RedirectWillChangeRequestUrl()
        {
            SimpleHttpContext context = SimpleHttpContext.Create("http://localhost/Production/Index");

            Assert.That(context.Request.Url.ToString(), Is.EqualTo("http://localhost/Production/Index"));

            context.Response.Redirect("http://localhost/Quality/Index");
            Assert.That(context.Request.Url.ToString(), Is.EqualTo("http://localhost/Quality/Index"));
        }
Beispiel #2
0
        public SimpleHttpContext WithSessionsDisabled()
        {
            SimpleHttpContext newContext = new SimpleHttpContext(request.Url.ToString())
            {
                Session = SimpleHttpSession.Create(false)
            };

            request.Dispose();
            response.Dispose();
            return(newContext);
        }
Beispiel #3
0
        public SimpleHttpContext WithRequestsNotAuthenticated()
        {
            SimpleHttpContext newContext = new SimpleHttpContext(request.Url.ToString())
            {
                Session = SimpleHttpSession.Create(false),
                Request = SimpleHttpRequest.Create(request.Url.ToString(), request.Cookies, false)
            };

            request.Dispose();
            response.Dispose();
            return(newContext);
        }
        public void OldRequestThrowsDisposed()
        {
            SimpleHttpContext context = SimpleHttpContext.Create("http://localhost/Production/Index");
            var oldRequest            = context.Request;
            var oldResponse           = context.Response;

            context.Response.Redirect("http://localhost/Quality/Index");
            Uri url = null;

            Assert.Throws <ObjectDisposedException>(() => { url = oldRequest.Url; });
            Assert.That(url, Is.Null);

            Assert.Throws <ObjectDisposedException>(() => oldResponse.Redirect("http://localhost"));
        }
        public void RedirectWillChangeTakeResponseCookiesToRequest()
        {
            SimpleHttpContext context = SimpleHttpContext.Create("http://localhost/Production/Index");

            Assert.That(context.Request.Url.ToString(), Is.EqualTo("http://localhost/Production/Index"));

            Assert.That(context.Request.Cookies, Is.Empty);
            Assert.That(context.Response.Cookies, Is.Empty);
            context.Response.Cookies.Add(new HttpCookie("Test", "UnitTest"));
            Assert.That(context.Response.Cookies, Is.Not.Empty);

            context.Response.Redirect("http://localhost/Quality/Index");
            Assert.That(context.Request.Url.ToString(), Is.EqualTo("http://localhost/Quality/Index"));
            Assert.That(context.Request.Cookies, Is.Not.Empty);
            Assert.That(context.Response.Cookies, Is.Empty);
        }
        public void WithSessionsDisabled()
        {
            SimpleHttpContext context = SimpleHttpContext.Create("http://localhost").WithSessionsDisabled();

            Assert.That(context.Session.Enabled, Is.False);
        }