add test that C# can read compressed messages

pull/6991/head
Jan Tattermusch 9 years ago
parent 0d896ef906
commit 4047d5d4b6
  1. 26
      src/csharp/Grpc.Core.Tests/CompressionTest.cs

@ -34,6 +34,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Grpc.Core;
@ -118,5 +119,30 @@ namespace Grpc.Core.Tests
await call.ResponseStream.ToListAsync();
}
[Test]
public void CanReadCompressedMessages()
{
var compressionMetadata = new Metadata
{
{ new Metadata.Entry("grpc-internal-encoding-request", "gzip") }
};
helper.UnaryHandler = new UnaryServerMethod<string, string>(async (req, context) =>
{
await context.WriteResponseHeadersAsync(compressionMetadata);
return req;
});
var stringBuilder = new StringBuilder();
for (int i = 0; i < 200000; i++)
{
stringBuilder.Append('a');
}
var request = stringBuilder.ToString();
var response = Calls.BlockingUnaryCall(helper.CreateUnaryCall(new CallOptions(compressionMetadata)), request);
Assert.AreEqual(request, response);
}
}
}

Loading…
Cancel
Save