예제 #1
0
        public void ShouldReadFirstMessage()
        {
            const int msgLength   = 1;
            int       frameLength = HEADER_LENGTH + msgLength;
            const int termOffset  = 0;

            A.CallTo(() => termBuffer.GetIntVolatile(0))
            .Returns(frameLength);
            A.CallTo(() => termBuffer.GetShort(FrameDescriptor.TypeOffset(0)))
            .Returns((short)HeaderFlyweight.HDR_TYPE_DATA);

            long readOutcome = TermReader.Read(termBuffer, termOffset, handler, int.MaxValue, header, errorHandler);

            Assert.That(TermReader.FragmentsRead(readOutcome), Is.EqualTo(1));

            A.CallTo(() => termBuffer.GetIntVolatile(0)).MustHaveHappened();
            A.CallTo(() => handler(termBuffer, HEADER_LENGTH, msgLength, A <Header> ._)).MustHaveHappened();
        }
예제 #2
0
        public void ShouldReadFirstMessage()
        {
            const int msgLength          = 1;
            int       frameLength        = HEADER_LENGTH + msgLength;
            int       alignedFrameLength = BitUtil.Align(frameLength, FrameDescriptor.FRAME_ALIGNMENT);
            const int termOffset         = 0;

            A.CallTo(() => termBuffer.GetIntVolatile(0))
            .Returns(frameLength);
            A.CallTo(() => termBuffer.GetShort(FrameDescriptor.TypeOffset(0)))
            .Returns((short)HeaderFlyweight.HDR_TYPE_DATA);

            int readOutcome = TermReader.Read(termBuffer, termOffset, handler, int.MaxValue, header, errorHandler, 0, subscriberPosition);

            Assert.That(TermReader.FragmentsRead(readOutcome), Is.EqualTo(1));

            A.CallTo(() => termBuffer.GetIntVolatile(0)).MustHaveHappened()
            .Then(A.CallTo(() => handler.OnFragment(termBuffer, HEADER_LENGTH, msgLength, A <Header> ._)).MustHaveHappened())
            .Then(A.CallTo(() => subscriberPosition.SetOrdered(alignedFrameLength)).MustHaveHappened());
        }
예제 #3
0
 /// <summary>
 /// Get the value of the header type field. The lower 16 bits are valid.
 /// </summary>
 /// <returns> the value of the header type field. </returns>
 /// <seealso cref="DataHeaderFlyweight"></seealso>
 public int HeaderType()
 {
     return(_buffer.GetShort(HeaderFlyweight.TYPE_FIELD_OFFSET, ByteOrder.LittleEndian) & 0xFFFF);
 }
예제 #4
0
 /// <summary>
 /// Get the value of the header type field. The lower 16 bits are valid.
 /// </summary>
 /// <returns> the value of the header type field. </returns>
 /// <seealso cref="DataHeaderFlyweight"/>
 public int HeaderType()
 {
     return(_buffer.GetShort(HeaderFlyweight.TYPE_FIELD_OFFSET) & 0xFFFF);
 }