Пример #1
0
        public async Task WontLetCallerToWriteMoreThanPredefinedLength()
        {
            var encoder = new HttpPassthroughResponseEncoder(new MemoryStream(), 8);
            await encoder.AppendAsync(new byte[2], 0, 2);

            Assert.Throws <InvalidOperationException>(() =>
            {
                try
                {
                    encoder.AppendAsync(new byte[2], 0, 7).Wait(TimeSpan.FromSeconds(5));
                }
                catch (AggregateException ex) {
                    throw ex.InnerException;
                }
            });
        }
Пример #2
0
        public async Task WriteDataAsIt(int testSize, int appendBufferSize)
        {
            var targetStream = new MemoryStream();
            var encoder      = new HttpPassthroughResponseEncoder(targetStream, testSize);
            var testData     = MockData.Bytes(testSize, seed: 7);

            // Begin test
            await encoder.AppendAsync(testData, appendBufferSize);

            await encoder.CompleteAsync();

            Assert.True(targetStream.ToArray().SequenceEqual(testData));
        }