Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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