Ejemplo n.º 1
0
        public void ShouldRedirect()
        {
            OwinContext context = OwinExtender.CreateRequestForPath("/redirect?dest=http://google.com");
            var         result  = context.ProcessRequest(this.Manager, null, this.CommonSalt, new NullLogger());

            result.Content.BodyAsString.Should().Be("Location: http://google.com");
            context.Response.Headers.Get("Location").Should().Be("http://google.com");
        }
Ejemplo n.º 2
0
        public void ShouldExecuteControllerAndHaveLoggingForExceptionsInProd()
        {
            this.applicationMode = ApplicationMode.Prod;
            OwinContext context        = OwinExtender.CreateRequestForPath("/exception");
            var         inMemoryLogger = new InMemoryLogger(LogLevels.Always);

            new Action(() => context.ProcessRequest(this.Manager, null, this.CommonSalt, inMemoryLogger))
            .ShouldThrow <NotImplementedException>();

            inMemoryLogger.Messages.Length.Should().BeGreaterThan(0);
        }
Ejemplo n.º 3
0
        public void ShouldSaveAndLoadSession()
        {
            OwinContext context = OwinExtender.CreateRequestForPath("/session-set?key-name=scott&value=youngblut");

            context.ProcessRequest(this.Manager, null, this.CommonSalt, new NullLogger());

            OwinContext secondContext = OwinExtender.CreateRequestForPath("/session-get?key-name=scott");

            secondContext.SetCookies(context.GetCookies());
            var result = secondContext.ProcessRequest(this.Manager, null, this.CommonSalt, new NullLogger());

            result.Content.BodyAsString.Should().Be("youngblut");
        }
Ejemplo n.º 4
0
        public void ShouldSaveAndLoadFlashWithRedirectKeepsValue()
        {
            OwinContext context = OwinExtender.CreateRequestForPath("/flash-set-with-redirect?key-name=scott&value=youngblut");

            context.ProcessRequest(this.Manager, null, this.CommonSalt, new InMemoryLogger(LogLevels.Off));

            OwinContext secondContext = OwinExtender.CreateRequestForPath("/flash-get?key-name=scott");

            secondContext.SetCookies(context.GetCookies());
            var result = secondContext.ProcessRequest(this.Manager, null, this.CommonSalt, new InMemoryLogger(LogLevels.Off));

            result.Content.BodyAsString.Should().Be("youngblut");
        }
Ejemplo n.º 5
0
        public void ShouldExecuteControllerAndHaveLoggingForExceptions()
        {
            this.applicationMode = ApplicationMode.Dev;
            OwinContext context        = OwinExtender.CreateRequestForPath("/exception");
            var         inMemoryLogger = new InMemoryLogger(LogLevels.Always);
            var         rezult         = context.ProcessRequest(this.Manager, null, this.CommonSalt, inMemoryLogger);

            inMemoryLogger.Messages.Length.Should().BeGreaterOrEqualTo(2);
            var message = inMemoryLogger.Messages.FirstOrDefault(x => x.Message.Contains("Oh Boy!"));

            message.Should().NotBeNull();
            message.ToString().Should().Contain("[ApplicationError]");
            message.ToString().Should().Contain("Op Ex");
//            rezult.Content.Body.Should().Contain("[ApplicationError]");
            rezult.Content.BodyAsString.Should().Contain("Op Ex");
            rezult.Content.BodyAsString.Should().Contain("Oh Boy!");
        }