Skip to content

Commit

Permalink
Added test using StreamWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Mar 20, 2013
1 parent 1f367a5 commit f4e3b5c
Showing 1 changed file with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public class Streams : IReturn<Stream>
public string Text { get; set; }
}

[Route("/streamwriter/{Text}")]
public class StreamWriters : IReturn<Stream>
{
public string Text { get; set; }
}

public class BuiltInTypesService : ServiceInterface.Service
{
public PocoResponse Any(Poco request)
Expand All @@ -74,7 +80,27 @@ public byte[] Any(Bytes request)
public byte[] Any(Streams request)
{
return new Guid(request.Text).ToByteArray();
}
}

public IStreamWriter Any(StreamWriters request)
{
return new StreamWriterResult(new Guid(request.Text).ToByteArray());
}
}

public class StreamWriterResult : IStreamWriter
{
private byte[] result;

public StreamWriterResult(byte[] result)
{
this.result = result;
}

public void WriteTo(Stream responseStream)
{
responseStream.Write(result, 0, result.Length);
}
}

public class BuiltInTypesAppHost : AppHostHttpListenerBase
Expand Down Expand Up @@ -256,6 +282,18 @@ public void Can_download_Streams_response_Async(IServiceClient client)

Assert.That(new Guid(bytes), Is.EqualTo(guid));
}

[Test, TestCaseSource("RestClients")]
public void Can_download_StreamWroter_response(IRestClient client)
{
var guid = Guid.NewGuid();
Stream response = client.Get(new StreamWriters { Text = guid.ToString() });
using (response)
{
var bytes = response.ReadFully();
Assert.That(new Guid(bytes), Is.EqualTo(guid));
}
}

}
}

0 comments on commit f4e3b5c

Please sign in to comment.