예제 #1
0
        public void WriteDelta()
        {
            // Arrange
            int  extra   = -1;
            long delta   = -1L;
            long initial = -1L;

            m_mockBinaryWriter.Setup(writer => writer.Write(It.IsAny <byte[]>(), 0, It.IsAny <int>()))
            .Callback <byte[], int, int>((b, i, c) =>
            {
                extra   = b[4];
                delta   = BigEndianConverter.GetInt64(b, 24);
                initial = BigEndianConverter.GetInt64(b, 32);
            }).Returns(0);
            m_builder.Reset();
            m_builder.WriteOperation(RequestOperation.Increment);

            // Act
            m_builder.WriteDelta(10L, 1001L);

            // Assert
            m_builder.WriteTo(m_mockBinaryWriter.Object);
            Assert.Equal(20, extra);
            Assert.Equal(10L, delta);
            Assert.Equal(1001L, initial);
        }
예제 #2
0
        public void WriteDelta()
        {
            // Arrange
            string result = null;

            m_mockBinaryWriter.Setup(writer => writer.Write(It.IsAny <byte[]>(), 0, It.IsAny <int>()))
            .Callback <byte[], int, int>((b, i, c) =>
                                         result = Encoding.ASCII.GetString(b, i, c - 2)).Returns(0);

            // Act
            m_builder.WriteDelta(10L, 0L);

            // Assert
            m_builder.WriteTo(m_mockBinaryWriter.Object);
            Assert.Equal(" 10", result);
        }