public void GetMany(GetOperation operation, byte[][] keys) { m_builder .Reset() .WriteOperation((RequestOperation)operation); foreach (var key in keys) { m_builder.WriteKey(key); } }
public void Delete(byte[] key, bool noreply) { m_builder .Reset() .WriteOperation(RequestOperation.Delete); if (noreply) { m_builder.WriteNoReply(); } m_builder.WriteKey(key); }
public void WriteKey() { // Arrange int keylength = -1; string result = string.Empty; m_mockBinaryWriter.Setup(writer => writer.Write(It.IsAny <byte[]>(), 0, It.IsAny <int>())) .Callback <byte[], int, int>((b, i, c) => { keylength = BigEndianConverter.GetInt16(b, 2); result = Encoding.ASCII.GetString(b, 24, 5); }).Returns(0); m_builder.Reset(); m_builder.WriteOperation(RequestOperation.Set); // Act m_builder.WriteKey(Encoding.ASCII.GetBytes("Hello")); // Assert m_builder.WriteTo(m_mockBinaryWriter.Object); Assert.Equal(5, keylength); Assert.Equal("Hello", result); }
public void WriteKey() { // Arrange var key = "Key1"; 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.WriteKey(Encoding.ASCII.GetBytes(key)); // Assert m_builder.WriteTo(m_mockBinaryWriter.Object); Assert.Equal(" " + key, result); }