Permalink
Browse files

Merge pull request #29 from ianbattersby/CodeGenTestFix-i27

HandlerRunnerBuildTests use local IMediaType to resolve test fail
  • Loading branch information...
2 parents 6b6998f + 5a66b87 commit 8bdf22f4c095f79c57ee4d6cbada104be44db029 @markrendle committed Sep 4, 2012
Showing with 23 additions and 2 deletions.
  1. +23 −2 Tests/Simple.Web.CodeGeneration.Tests/HandlerRunnerBuilderTest.cs
@@ -1,17 +1,20 @@
namespace Simple.Web.CodeGeneration.Tests
{
+ using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
+ using System.Threading.Tasks;
using Behaviors;
+ using Helpers;
using Http;
- using JsonFx;
+ using MediaTypeHandling;
using Mocks;
using Xunit;
public class HandlerRunnerBuilderTest
{
- static readonly JsonFx.JsonMediaTypeHandler _ = new JsonMediaTypeHandler();
+ static readonly IMediaTypeHandler JsonMediaTypeHandler = new TestJsonMediaTypeHandler();
private static readonly byte[] TestJson = Encoding.UTF8.GetBytes("{\"Called\": true, \"Test\":\"Pass\"}\r\n");
[Fact]
@@ -189,4 +192,22 @@ public class FooModel
public string Test { get; set; }
public bool Called { get; set; }
}
+
+ [MediaTypes(MediaType.Json, "application/*+json")]
+ public class TestJsonMediaTypeHandler : IMediaTypeHandler
+ {
+ public object Read(Stream inputStream, Type inputType)
+ {
+ return new FooModel()
+ {
+ Test = "Pass",
+ Called = true
+ };
+ }
+
+ public Task Write(IContent content, Stream outputStream)
+ {
+ return TaskHelper.Completed();
+ }
+ }
}

0 comments on commit 8bdf22f

Please sign in to comment.