Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Added additional test to make sure it handles with and without charset
Browse files Browse the repository at this point in the history
  • Loading branch information
grumpydev committed Apr 5, 2011
1 parent a000b52 commit ddc0008
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Nancy.Tests/Unit/RequestFixture.cs
Expand Up @@ -146,6 +146,30 @@ public void Should_set_extract_form_data_from_body_when_content_type_is_x_www_fo
memory.Position = 0;

var headers =
new Dictionary<string, IEnumerable<string>>
{
{ "content-type", new[] { "application/x-www-form-urlencoded" } }
};

// When
var request = new Request("POST", "/", headers, memory, "http");

// Then
((string)request.Form.name).ShouldEqual("John Doe");
}

[Fact]
public void Should_set_extract_form_data_from_body_when_content_type_is_x_www_form_urlencoded_with_character_set()
{
// Given
const string bodyContent = "name=John+Doe&gender=male&family=5&city=kent&city=miami&other=abc%0D%0Adef&nickname=J%26D";
var memory = CreateRequestStream();
var writer = new StreamWriter(memory);
writer.Write(bodyContent);
writer.Flush();
memory.Position = 0;

var headers =
new Dictionary<string, IEnumerable<string>>
{
{ "content-type", new[] { "application/x-www-form-urlencoded; charset=UTF-8" } }
Expand Down

0 comments on commit ddc0008

Please sign in to comment.