Created
March 23, 2011 13:00
-
-
Save thecodejunkie/883061 to your computer and use it in GitHub Desktop.
Using a custom extension to the Nancy test harness to be able to add multipart/form-data encoded data into the request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
public void Should_add_multipart_formdata_encoded_files_to_request_filestream() | |
{ | |
// Given | |
var stream = | |
CreateFakeFileStream("This is the contents of a file"); | |
var multipart = new BrowserContextMultipartFormData(x => { | |
x.AddFile("foo", "foo.txt", "text/plain", stream); | |
}); | |
// When | |
var context = browser.Get("/", (with) => { | |
with.HttpRequest(); | |
with.MultiPartFormData(multipart); | |
}); | |
// Then | |
context.Request.Files.ShouldHaveCount(1); | |
context.Request.Files.First().ContentType.ShouldEqual("text/plain"); | |
context.Request.Files.First().Name.ShouldEqual("foo.txt"); | |
context.Request.Files.First().Value.AsString().ShouldEqual("This is the contents of a file"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment