Created
April 7, 2012 02:19
-
-
Save taylonr/2324543 to your computer and use it in GitHub Desktop.
Integration test for OpenRasta
This file contains 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
[Test] | |
public void Should_Add_User() | |
{ | |
var user = new UserInput {Email = "autotest@example.com", FirstName = "automated", LastName = "user", Password = "abc"}; | |
using (var host = new InMemoryHost(new Configuration())) | |
{ | |
var req = new InMemoryRequest | |
{ | |
Uri = new Uri("http://localhost/users"), | |
HttpMethod = "POST" | |
}; | |
req.Entity.ContentType = MediaType.Json; | |
req.Entity.Headers["Accept"] = "application/json"; | |
var serializer = new DataContractJsonSerializer(typeof(UserInput)); | |
serializer.WriteObject(req.Entity.Stream, user); | |
req.Entity.Stream.Seek(0, SeekOrigin.Begin); | |
req.Entity.ContentLength = req.Entity.Stream.Length; | |
var response = host.ProcessRequest(req); | |
response.StatusCode.ShouldEqual(201); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment