Commit 2ce669f2 authored by Marc Gravell's avatar Marc Gravell

Merge pull request #133 from luberg/master

Issue #111: HashSet with RedisValue.EmptyString do not work as ""
parents 1aeafcfe 22fb8d8e
...@@ -180,6 +180,11 @@ public void TestGet() ...@@ -180,6 +180,11 @@ public void TestGet()
var set2 = conn.HashSetAsync("hashkey", "field-blob", Encoding.UTF8.GetBytes("value3")); var set2 = conn.HashSetAsync("hashkey", "field-blob", Encoding.UTF8.GetBytes("value3"));
var val3 = conn.HashGetAsync("hashkey", "field-blob"); var val3 = conn.HashGetAsync("hashkey", "field-blob");
var set3 = conn.HashSetAsync("hashkey", "empty_type1", "");
var val4 = conn.HashGetAsync("hashkey", "empty_type1");
var set4 = conn.HashSetAsync("hashkey", "empty_type2", RedisValue.EmptyString);
var val5 = conn.HashGetAsync("hashkey", "empty_type2");
Assert.AreEqual(null, (string)val0.Result); Assert.AreEqual(null, (string)val0.Result);
Assert.AreEqual(true, set0.Result); Assert.AreEqual(true, set0.Result);
Assert.AreEqual("value1", (string)val1.Result); Assert.AreEqual("value1", (string)val1.Result);
...@@ -189,6 +194,10 @@ public void TestGet() ...@@ -189,6 +194,10 @@ public void TestGet()
Assert.AreEqual(true, set2.Result); Assert.AreEqual(true, set2.Result);
Assert.AreEqual("value3", (string)val3.Result); Assert.AreEqual("value3", (string)val3.Result);
Assert.AreEqual(true, set3.Result);
Assert.AreEqual("", (string)val4.Result);
Assert.AreEqual(true, set4.Result);
Assert.AreEqual("", (string)val5.Result);
} }
} }
[Test] [Test]
......
...@@ -10,12 +10,12 @@ public struct RedisValue : IEquatable<RedisValue>, IComparable<RedisValue>, ICom ...@@ -10,12 +10,12 @@ public struct RedisValue : IEquatable<RedisValue>, IComparable<RedisValue>, ICom
{ {
internal static readonly RedisValue[] EmptyArray = new RedisValue[0]; internal static readonly RedisValue[] EmptyArray = new RedisValue[0];
static readonly byte[] EmptyByteArr = new byte[0];
private static readonly RedisValue private static readonly RedisValue
@null = new RedisValue(0, null), @null = new RedisValue(0, null),
emptyString = new RedisValue(0, EmptyByteArr); emptyString = new RedisValue(0, EmptyByteArr);
static readonly byte[] EmptyByteArr = new byte[0];
private static readonly byte[] IntegerSentinel = new byte[0]; private static readonly byte[] IntegerSentinel = new byte[0];
private readonly byte[] valueBlob; private readonly byte[] valueBlob;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment