[InlineData(40, 32, 64)] // memory sizes are powers of 2. public void CheckMinimumSegmentSizeWithGetMemory(int minimumSegmentSize, int getMemorySize, int expectedSize) { var writer = new StreamPipeWriter(new MemoryStream(), minimumSegmentSize); var memory = writer.GetMemory(getMemorySize); Assert.Equal(expectedSize, memory.Length); }
public async Task CanAdvanceWithPartialConsumptionOfFirstSegment(int firstWriteLength) { Writer = new StreamPipeWriter(Stream, MinimumSegmentSize, new TestMemoryPool(maxBufferSize: 20000)); await Writer.WriteAsync(Encoding.ASCII.GetBytes("a")); var memory = Writer.GetMemory(firstWriteLength); Writer.Advance(firstWriteLength); memory = Writer.GetMemory(); Writer.Advance(memory.Length); await Writer.FlushAsync(); Assert.Equal(firstWriteLength + memory.Length + 1, Read().Length); }