Skip to content

Instantly share code, notes, and snippets.

@taylonr
Created April 7, 2012 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taylonr/2324543 to your computer and use it in GitHub Desktop.
Save taylonr/2324543 to your computer and use it in GitHub Desktop.
Integration test for OpenRasta
[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