So I have this unit test:
[TestMethod]
public void TestNullString()
{
String expectedTestValue = null;
var uid = Guid.NewGuid().ToString();
redis.Wait(redis.Strings.Set(db, uid, expectedTestValue));
var testValue = redis.Wait(redis.Strings.GetString(db, uid));
Assert.AreEqual(expectedTestValue, testValue);
}
The outcome is a timeout. Is this supposed to happen or am I doing something wrong?
Redis has no concept of null
. Either a string is (i.e. "abc"
or ""
- zero-length strings are fine), or it is not (i.e. the key does not exist).
The "bug" here is that BookSleeve does not check for a null
value to .String.Set
and throw an exception. That will be rectified imminently.
What is happening currently is that the code is failing when writing the command to the stream - in particular, the redis binary protocol means that you declare the number of arguments before sending the data, i.e. (simplified) "SET", "2", "key", "value" - and since it never writes the value, the server doesn't even get the chance to send a "that isn't valid" reply; as far as the server is concerned, it is still waiting for an extra parameter.