public void ShouldSetContentTypeToApplicationHalJson() { var context = new NancyContext(); var config = new HalConfiguration(); var processor = new HalJsonResponseProcessor(config, new[] { JsonSerializer }); var response = (JsonResponse)processor.Process(new MediaRange("application/hal+json"), new PetOwner() { Name = "Bob " }, context); Assert.Equal("application/hal+json", response.ContentType); }
private JObject Serialize(object model, IProvideHalTypeConfiguration config, NancyContext context = null) { if (context == null) { context = new NancyContext(); } var processor = new HalJsonResponseProcessor(config, new[] { JsonSerializer }); var response = (JsonResponse)processor.Process(new MediaRange("application/hal+json"), model, context); var stream = new MemoryStream(); response.Contents.Invoke(stream); stream.Seek(0, SeekOrigin.Begin); var text = new StreamReader(stream).ReadToEnd(); Console.WriteLine(text); return(JObject.Parse(text)); }