public void GetSpan_WriteFillThenRequest0() { var prefixWriter = new PrefixingBufferWriter <byte>(this.sequence, Prefix.Length, 0); var span = prefixWriter.GetSpan(5); prefixWriter.Advance(span.Length); span = prefixWriter.GetSpan(0); Assert.NotEqual(0, span.Length); }
public void GetSpan_WriteWithHint0() { var prefixWriter = new PrefixingBufferWriter <byte>(this.sequence, Prefix.Length, 0); var span = prefixWriter.GetSpan(0); Assert.NotEqual(0, span.Length); }
public void SomePayload( bool largArrayPool, bool excessSpan, [CombinatorialValues(0, PayloadSize - 1, PayloadSize, PayloadSize + 1)] int sizeHint, [CombinatorialValues(1, 2, 3, PayloadSize)] int stepCount) { this.mockPool.MinArraySizeFactor = largArrayPool ? 2.0 : 1.0; var prefixWriter = new PrefixingBufferWriter <byte>(this.sequence, Prefix.Length, sizeHint); int stepSize = Payload.Length / stepCount; int expectedLength = 0; for (int i = 0; i < stepCount - 1; i++) { var spanToWrite = Payload.Span.Slice(stepSize * i, stepSize); if (excessSpan) { var targetSpan = prefixWriter.GetSpan((int)(spanToWrite.Length * 1.5)); spanToWrite.CopyTo(targetSpan); prefixWriter.Advance(spanToWrite.Length); } else { prefixWriter.Write(spanToWrite); } expectedLength += spanToWrite.Length; Assert.Equal(expectedLength, prefixWriter.Length); } // The last step fills in the remainder as well. prefixWriter.Write(Payload.Span.Slice(stepSize * (stepCount - 1))); this.PayloadCompleteHelper(prefixWriter); }