Exemplo n.º 1
0
        public void WriteValue()
        {
            // Arrange
            string result = string.Empty;

            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, 24, 5);
            }).Returns(0);
            m_builder.Reset();
            m_builder.WriteOperation(RequestOperation.Set);

            // Act
            m_builder.WriteValue(new ArraySegment <byte>(Encoding.ASCII.GetBytes("World")));

            // Assert
            m_builder.WriteTo(m_mockBinaryWriter.Object);
            Assert.Equal("World", result);
        }
Exemplo n.º 2
0
        public void WriteValue()
        {
            // 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.WriteValue(new ArraySegment <byte>(Encoding.ASCII.GetBytes("test")));

            // Assert
            m_builder.WriteTo(m_mockBinaryWriter.Object);
            Assert.Equal("\r\ntest", result);
        }
Exemplo n.º 3
0
        public void Store(StorePacket packet, bool noreply)
        {
            m_builder
            .Reset()
            .WriteOperation((RequestOperation)packet.Operation)
            .WriteKey(packet.Key)
            .WriteFlags(packet.Flags)
            .WriteExpires(packet.Expires)
            .WriteLength(packet.Value.Count)
            .WriteVersion(packet.Version);

            if (noreply)
            {
                m_builder.WriteNoReply();
            }

            m_builder.WriteValue(packet.Value);
        }