예제 #1
0
        internal void VerifyGoAway(Http3FrameWithPayload frame, long expectedLastStreamId, Http3ErrorCode expectedErrorCode)
        {
            Assert.Equal(Http3FrameType.GoAway, frame.Type);
            var payload = frame.Payload;

            Assert.True(VariableLengthIntegerHelper.TryRead(payload.Span, out var streamId, out var _));
            Assert.Equal(expectedLastStreamId, streamId);
        }
예제 #2
0
        public void TryRead_FromReadOnlySpan_BufferEmpty()
        {
            ReadOnlySpan <byte> readOnlySpan = new ReadOnlySpan <byte>();
            bool isSuccess = VariableLengthIntegerHelper.TryRead(readOnlySpan,
                                                                 out long value, out int bytesRead);

            Assert.False(isSuccess);
            Assert.Equal(0, value);
            Assert.Equal(0, bytesRead);
        }
예제 #3
0
        public void TryRead_FromReadOnlySpan_BufferNotEmpty_InitialFourByteLengthMask_TryReadNotUInt32BigEndian()
        {
            ReadOnlySpan <byte> readOnlySpan = new ReadOnlySpan <byte>(new byte[]
            {
                128
            });
            bool isSuccess = VariableLengthIntegerHelper.TryRead(readOnlySpan,
                                                                 out long value, out int bytesRead);

            Assert.False(isSuccess);
            Assert.Equal(0, value);
            Assert.Equal(0, bytesRead);
        }
예제 #4
0
        public void TryRead_FromReadOnlySpan_BufferNotEmpty_InitialOneByteLengthMask()
        {
            ReadOnlySpan <byte> readOnlySpan = new ReadOnlySpan <byte>(new byte[]
            {
                1
            });
            bool isSuccess = VariableLengthIntegerHelper.TryRead(readOnlySpan,
                                                                 out long value, out int bytesRead);

            Assert.True(isSuccess);
            Assert.Equal(1, value);
            Assert.Equal(1, bytesRead);
        }
예제 #5
0
        internal void VerifyGoAway(Http3FrameWithPayload frame, long expectedLastStreamId)
        {
            Http3InMemory.AssertFrameType(frame.Type, Http3FrameType.GoAway);
            var payload = frame.Payload;

            if (!VariableLengthIntegerHelper.TryRead(payload.Span, out var streamId, out var _))
            {
                throw new InvalidOperationException("Failed to read GO_AWAY stream ID.");
            }
            if (streamId != expectedLastStreamId)
            {
                throw new InvalidOperationException($"Expected stream ID {expectedLastStreamId}, got {streamId}.");
            }
        }
예제 #6
0
        public void TryRead_FromReadOnlySpan_BufferNotEmpty_InitialEightByteLengthMask_TryReadUInt64BigEndian()
        {
            ReadOnlySpan <byte> readOnlySpan = new ReadOnlySpan <byte>(
                new byte[]
            {
                192, 0, 0, 0,
                0, 0, 0, 4
            });
            bool isSuccess = VariableLengthIntegerHelper.TryRead(readOnlySpan,
                                                                 out long value, out int bytesRead);

            Assert.True(isSuccess);
            Assert.Equal(4, value);
            Assert.Equal(8, bytesRead);
        }