public void ShouldSetNullContentType() { var content = new SimpleContent { BodyContent = "<root>My Body</root>" }; var owinContext = new OwinContext(); var httpContext = new HttpContext(this.App(), new NullLogger(), null, owinContext, new HttpContextSettings()); var result = new ResponseResult(httpContext.Response, content); result.Content.BodyAsString.Should().Be("<root>My Body</root>"); owinContext.Response.ContentType.Should().Be("text/plain"); }
public void ShouldSetValues() { var content = new SimpleContent { BodyContent = "<root>My Body</root>", ContentType = "text/xml" }; var owinContext = new OwinContext(); var httpContext = new HttpContext(this.App(), new NullLogger(), null, owinContext, new HttpContextSettings()); var result = new ResponseResult(httpContext.Response, content); System.Text.Encoding.Default.GetString(result.Content.Body).Should().Be("<root>My Body</root>"); result.Content.ContentType.Should().Be("text/xml"); owinContext.Response.ContentType.Should().Be("text/xml"); }
public void ShouldSetValuesNullContentType() { var content = new SimpleContent { BodyContent = "<root>My Body</root>" }; var owinContext = new OwinContext(); var httpContext = new HttpContext(this.App(), new NullLogger(), null, owinContext, new HttpContextSettings()); var result = new ResponseResult(httpContext.Response, content); result.WithLocation("http://google.com/") .WithStatusCode(HttpStatusCode.Accepted) .As("text/html"); owinContext.Response.Headers.Get("Location").Should().Be("http://google.com/"); owinContext.Response.StatusCode.Should().Be(202); owinContext.Response.ContentType.Should().Be("text/html"); }