public async Task CopyTo_MessageStreamCopied() { var streamProvider = new MessageStreamProvider <IRawInboundEnvelope>(); var chunkStream = new ChunkStream(streamProvider.CreateStream <IRawInboundEnvelope>()); var output = new MemoryStream(Encoding.UTF8.GetBytes("some junk-")); var copyTask = Task.Run(() => chunkStream.CopyTo(output)); await streamProvider.PushAsync( new RawInboundEnvelope( Encoding.UTF8.GetBytes("Silver"), null, TestConsumerEndpoint.GetDefault(), "test", new TestOffset())); await streamProvider.PushAsync( new RawInboundEnvelope( Encoding.UTF8.GetBytes("back"), null, TestConsumerEndpoint.GetDefault(), "test", new TestOffset())); await streamProvider.CompleteAsync(); await copyTask; chunkStream.Close(); Encoding.UTF8.GetString(output.ToArray()).Should().Be("Silverback"); }