Beispiel #1
0
        public void OnBeginRequest_Should_Redirect_When_Requesting_WWW_Url()
        {
            var httpContext = MvcTestHelper.GetHttpContext();

            httpContext.HttpRequest.SetupGet(r => r.Url).Returns(new Uri("http://www.dotnetshoutout.com/Upcoming"));

            httpContext.HttpResponse.SetupSet(r => r.StatusCode       = (int)HttpStatusCode.MovedPermanently).Verifiable();
            httpContext.HttpResponse.SetupSet(r => r.Status           = "301 Moved Permanently").Verifiable();
            httpContext.HttpResponse.SetupSet(r => r.RedirectLocation = "http://dotnetshoutout.com/Upcoming").Verifiable();
            httpContext.HttpResponse.Setup(r => r.End()).Verifiable();

            var module = new RemoveWwwRedirector();

            module.OnBeginRequest(httpContext.Object);

            httpContext.Verify();
        }
Beispiel #2
0
        public void OnBeginRequest_Should_Redirect_WWW_Less_Url_When_Requesting_WWW_Url()
        {
            var httpContext = MvcTestHelper.GetHttpContext();

            httpContext.HttpRequest.ExpectGet(r => r.Url).Returns(new Uri("http://www.dotnetshoutout.com/Upcoming"));

            httpContext.HttpResponse.ExpectSet(r => r.StatusCode).Verifiable();
            httpContext.HttpResponse.ExpectSet(r => r.Status).Verifiable();
            httpContext.HttpResponse.ExpectSet(r => r.RedirectLocation).Verifiable();
            httpContext.HttpResponse.Expect(r => r.End()).Verifiable();

            var module = new RemoveWwwRedirector();

            module.OnBeginRequest(httpContext.Object);

            httpContext.Verify();
        }