Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test using StreamWriter

  • Loading branch information...
commit f4e3b5c3de78b06928be91eb821a23821975dce5 1 parent 1f367a5
@mythz mythz authored
View
40 tests/ServiceStack.WebHost.Endpoints.Tests/ServiceClientsBuiltInResponseTests.cs
@@ -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)
@@ -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
@@ -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));
+ }
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.