Exemplo n.º 1
0
        public void ShouldNotOverwriteExistingFrame()
        {
            const int gapOffset = 0;
            const int gapLength = 64;

            dataFlyweight.FrameLength(32);

            Assert.IsFalse(TermGapFiller.TryFillGap(metaDataBuffer, termBuffer, TERM_ID, gapOffset, gapLength));
        }
Exemplo n.º 2
0
        public void ShouldFillGapAtBeginningOfTerm()
        {
            const int gapOffset = 0;
            const int gapLength = 64;

            Assert.IsTrue(TermGapFiller.TryFillGap(metaDataBuffer, termBuffer, TERM_ID, gapOffset, gapLength));

            Assert.That(dataFlyweight.FrameLength(), Is.EqualTo(gapLength));
            Assert.That(dataFlyweight.TermOffset(), Is.EqualTo(gapOffset));
            Assert.That(dataFlyweight.SessionId(), Is.EqualTo(SESSION_ID));
            Assert.That(dataFlyweight.TermId(), Is.EqualTo(TERM_ID));
            Assert.That(dataFlyweight.HeaderType(), Is.EqualTo(FrameDescriptor.PADDING_FRAME_TYPE));
            Assert.That(dataFlyweight.Flags(), Is.EqualTo(FrameDescriptor.UNFRAGMENTED));
        }
Exemplo n.º 3
0
        public void ShouldFillGapAfterExistingFrame()
        {
            const int gapOffset = 128;
            const int gapLength = 64;

            dataFlyweight.SessionId(SESSION_ID).TermId(TERM_ID).StreamId(STREAM_ID).Flags(FrameDescriptor.UNFRAGMENTED).FrameLength(gapOffset);
            dataFlyweight.SetMemory(0, gapOffset - DataHeaderFlyweight.HEADER_LENGTH, (byte)'x');

            Assert.IsTrue(TermGapFiller.TryFillGap(metaDataBuffer, termBuffer, TERM_ID, gapOffset, gapLength));

            dataFlyweight.Wrap(termBuffer, gapOffset, termBuffer.Capacity - gapOffset);
            Assert.That(dataFlyweight.FrameLength(), Is.EqualTo(gapLength));
            Assert.That(dataFlyweight.TermOffset(), Is.EqualTo(gapOffset));
            Assert.That(dataFlyweight.SessionId(), Is.EqualTo(SESSION_ID));
            Assert.That(dataFlyweight.TermId(), Is.EqualTo(TERM_ID));
            Assert.That(dataFlyweight.HeaderType(), Is.EqualTo(FrameDescriptor.PADDING_FRAME_TYPE));
            Assert.That(dataFlyweight.Flags(), Is.EqualTo(FrameDescriptor.UNFRAGMENTED));
        }