Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Added test for checking if the custom headers are copied over when co…
Browse files Browse the repository at this point in the history
…mpressing content
  • Loading branch information
azzlack committed Jun 24, 2015
1 parent 57a5844 commit e17c064
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
Binary file not shown.
Binary file not shown.
11 changes: 9 additions & 2 deletions src/Tests/Controllers/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@

using global::Tests.Models;

using Microsoft.AspNet.WebApi.MessageHandlers.Compression.Attributes;

public class TestController : ApiController
{
public async Task<HttpResponseMessage> Get()
{
return this.Request.CreateResponse(new TestModel("Get()"));
}

[Route("api/test/customheader")]
public async Task<HttpResponseMessage> GetCustomHeader()
{
var response = this.Request.CreateResponse(new TestModel("Get()"));
response.Headers.Add("DataServiceVersion", "3.0");

return response;
}

public async Task<HttpResponseMessage> Get(string id)
{
return this.Request.CreateResponse(new TestModel("Get(" + id + ")"));
Expand Down
13 changes: 13 additions & 0 deletions src/Tests/Tests/Common/TestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ public async Task Get_WhenMessageHandlerIsConfigured_ShouldReturnCompressedConte
Assert.AreEqual("Get()", result.Data);
}

public async Task Get_WhenGivenCustomHeader_ShouldReturnCompressedContentWithCustomHeader()
{
var response = await this.client.GetAsync("http://localhost:55399/api/test/customheader");

Console.WriteLine("Content: {0}", await response.Content.ReadAsStringAsync());

Assert.IsTrue(response.Content.Headers.ContentEncoding.Contains("gzip"));

Console.WriteLine("Content-Length: {0}", response.Content.Headers.ContentLength);

Assert.IsTrue(response.Headers.Contains("DataServiceVersion"), "The response did not contain the DataServiceVersion header");
}

public async Task GetImage_WhenMessageHandlerIsConfigured_ShouldReturnCompressedContent()
{

Expand Down
6 changes: 6 additions & 0 deletions src/Tests/Tests/Facade/OwinHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public async void Get_WhenMessageHandlerIsConfigured_ShouldReturnCompressedConte
await this.testFixture.Get_WhenMessageHandlerIsConfigured_ShouldReturnCompressedContent();
}

[Test]
public async void Get_WhenGivenCustomHeader_ShouldReturnCompressedContentWithCustomHeader()
{
await this.testFixture.Get_WhenGivenCustomHeader_ShouldReturnCompressedContentWithCustomHeader();
}

[Test]
public async void GetImage_WhenMessageHandlerIsConfigured_ShouldReturnCompressedContent()
{
Expand Down
6 changes: 6 additions & 0 deletions src/Tests/Tests/Facade/WebHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public async void Get_WhenMessageHandlerIsConfigured_ShouldReturnCompressedConte
await this.testFixture.Get_WhenMessageHandlerIsConfigured_ShouldReturnCompressedContent();
}

[Test]
public async void Get_WhenGivenCustomHeader_ShouldReturnCompressedContentWithCustomHeader()
{
await this.testFixture.Get_WhenGivenCustomHeader_ShouldReturnCompressedContentWithCustomHeader();
}

[Test]
public async void GetImage_WhenMessageHandlerIsConfigured_ShouldReturnCompressedContent()
{
Expand Down

0 comments on commit e17c064

Please sign in to comment.