Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added test using StreamWriter

  • Loading branch information...
commit f4e3b5c3de78b06928be91eb821a23821975dce5 1 parent 1f367a5
Demis Bellot mythz authored
40 tests/ServiceStack.WebHost.Endpoints.Tests/ServiceClientsBuiltInResponseTests.cs
@@ -49,6 +49,12 @@ public class Streams : IReturn<Stream>
49 49 public string Text { get; set; }
50 50 }
51 51
  52 + [Route("/streamwriter/{Text}")]
  53 + public class StreamWriters : IReturn<Stream>
  54 + {
  55 + public string Text { get; set; }
  56 + }
  57 +
52 58 public class BuiltInTypesService : ServiceInterface.Service
53 59 {
54 60 public PocoResponse Any(Poco request)
@@ -74,7 +80,27 @@ public byte[] Any(Bytes request)
74 80 public byte[] Any(Streams request)
75 81 {
76 82 return new Guid(request.Text).ToByteArray();
77   - }
  83 + }
  84 +
  85 + public IStreamWriter Any(StreamWriters request)
  86 + {
  87 + return new StreamWriterResult(new Guid(request.Text).ToByteArray());
  88 + }
  89 + }
  90 +
  91 + public class StreamWriterResult : IStreamWriter
  92 + {
  93 + private byte[] result;
  94 +
  95 + public StreamWriterResult(byte[] result)
  96 + {
  97 + this.result = result;
  98 + }
  99 +
  100 + public void WriteTo(Stream responseStream)
  101 + {
  102 + responseStream.Write(result, 0, result.Length);
  103 + }
78 104 }
79 105
80 106 public class BuiltInTypesAppHost : AppHostHttpListenerBase
@@ -256,6 +282,18 @@ public void Can_download_Streams_response_Async(IServiceClient client)
256 282
257 283 Assert.That(new Guid(bytes), Is.EqualTo(guid));
258 284 }
  285 +
  286 + [Test, TestCaseSource("RestClients")]
  287 + public void Can_download_StreamWroter_response(IRestClient client)
  288 + {
  289 + var guid = Guid.NewGuid();
  290 + Stream response = client.Get(new StreamWriters { Text = guid.ToString() });
  291 + using (response)
  292 + {
  293 + var bytes = response.ReadFully();
  294 + Assert.That(new Guid(bytes), Is.EqualTo(guid));
  295 + }
  296 + }
259 297
260 298 }
261 299 }

0 comments on commit f4e3b5c

Please sign in to comment.
Something went wrong with that request. Please try again.