public async Task ReadAsync_EmptyMessageAndTrailers_ParseMessageAndTrailers() { // Arrange var data = new byte[] { 0, 0, 0, 0, 0, 128, 0, 0, 0, 0 }; var trailingHeaders = new TestHttpHeaders(); var ms = new MemoryStream(data); var responseStream = new GrpcWebResponseStream(ms, trailingHeaders); // Act 1 var contentHeaderData = new byte[5]; var read1 = await ReadAsync(responseStream, contentHeaderData); // Assert 1 Assert.AreEqual(5, read1); Assert.AreEqual(0, contentHeaderData[0]); Assert.AreEqual(0, contentHeaderData[1]); Assert.AreEqual(0, contentHeaderData[2]); Assert.AreEqual(0, contentHeaderData[3]); Assert.AreEqual(0, contentHeaderData[4]); // Act 2 var read2 = await ReadAsync(responseStream, contentHeaderData); // Assert 2 Assert.AreEqual(0, read2); Assert.AreEqual(0, trailingHeaders.Count()); }
public async Task ReadAsync_EmptyMessage_ParseMessageAndTrailers() { // Arrange var data = Convert.FromBase64String("AAAAAACAAAAAEA0KZ3JwYy1zdGF0dXM6IDA="); var trailingHeaders = new TestHttpHeaders(); var ms = new MemoryStream(data); var responseStream = new GrpcWebResponseStream(ms, trailingHeaders); // Act 1 var contentHeaderData = new byte[5]; var read1 = await ReadAsync(responseStream, contentHeaderData); // Assert 1 Assert.AreEqual(5, read1); Assert.AreEqual(0, contentHeaderData[0]); Assert.AreEqual(0, contentHeaderData[1]); Assert.AreEqual(0, contentHeaderData[2]); Assert.AreEqual(0, contentHeaderData[3]); Assert.AreEqual(0, contentHeaderData[4]); // Act 2 var read2 = await ReadAsync(responseStream, contentHeaderData); // Assert 2 Assert.AreEqual(0, read2); Assert.AreEqual(1, trailingHeaders.Count()); Assert.AreEqual("0", trailingHeaders.GetValues("grpc-status").Single()); }