public void TestHIncrByFloat() { Redis.Del("test"); RedisGenericTest my_obj = RedisGenericTest.Create(); var hmsset_result = Redis.HMSet("test", my_obj); var hincrby_result = Redis.HIncrByFloat("test", "FloatField", 3.4); Assert.AreEqual(my_obj.FloatField + 3.4F, (float)hincrby_result); var hincrby_result2 = Redis.HIncrByFloat("test", "FloatField", -3.4); Assert.AreEqual(my_obj.FloatField + 3.4F - 3.4F, (float)hincrby_result2); var hincrby_result3 = Redis.HIncrByFloat("test", "DoubleField", 1.2); Assert.AreEqual(my_obj.DoubleField + 1.2, hincrby_result3); var hincrby_result4 = Redis.HIncrByFloat("test", "DoubleField", -3.4); Assert.AreEqual(my_obj.DoubleField + 1.2 - 3.4, hincrby_result4); Redis.Del("test"); }
public void TestHashCreate_Generic() { using (new RedisTestKeys(Redis, "test")) { var my_obj = RedisGenericTest.Create(); Assert.AreEqual("OK", Redis.HMSet("test", my_obj)); var redis_obj = Redis.HGetAll <RedisGenericTest>("test"); Assert.AreEqual(my_obj.StringField, redis_obj.StringField); Assert.AreEqual(my_obj.IntField, redis_obj.IntField); Assert.AreEqual(my_obj.UIntField, redis_obj.UIntField); Assert.AreEqual(my_obj.DoubleField, redis_obj.DoubleField); Assert.AreEqual(my_obj.FloatField, redis_obj.FloatField); Assert.AreEqual(my_obj.BoolField, redis_obj.BoolField); Assert.AreEqual(my_obj.LongField, redis_obj.LongField); Assert.AreEqual(my_obj.ULongField, redis_obj.ULongField); Assert.AreEqual(my_obj.ShortField, redis_obj.ShortField); Assert.AreEqual(my_obj.UShortField, redis_obj.UShortField); Assert.AreEqual(my_obj.ByteField, redis_obj.ByteField); Assert.AreEqual(my_obj.SByteField, redis_obj.SByteField); Assert.AreEqual(my_obj.CharField, redis_obj.CharField); Assert.IsNull(redis_obj.NullField); Assert.AreEqual(my_obj.DateTimeField.ToString(), redis_obj.DateTimeField.ToString()); Assert.AreEqual(my_obj.DateTimeOffsetField.ToString(), redis_obj.DateTimeOffsetField.ToString()); } using (new RedisTestKeys(Redis, "test")) { var obj = Redis.HGetAll <RedisGenericTest>("test"); Assert.IsNull(obj); } }
public void TestHMGet_Array() { Redis.Del("test"); var obj = RedisGenericTest.Create(); Redis.HMSet("test", obj); var res = Redis.HMGet("test", "StringField", "DoubleField"); Assert.AreEqual(obj.StringField, res[0]); Assert.AreEqual(obj.DoubleField.ToString(), res[1]); Redis.Del("test"); }
public void TestHIncrBy() { Redis.Del("test"); RedisGenericTest my_obj = RedisGenericTest.Create(); var hmsset_result = Redis.HMSet("test", my_obj); var hincrby_result = Redis.HIncrBy("test", "IntField", 3); Assert.AreEqual(my_obj.IntField + 3, hincrby_result); var hincrby_result2 = Redis.HIncrBy("test", "IntField", -3); Assert.AreEqual(my_obj.IntField + 3 - 3, hincrby_result2); Redis.Del("test"); }
public void TestHGet() { Redis.Del("test"); RedisGenericTest my_obj = RedisGenericTest.Create(); var hmsset_result = Redis.HMSet("test", my_obj); var hget_string_result = Redis.HGet("test", "StringField"); Assert.AreEqual(my_obj.StringField, hget_string_result); var hget_int_result = Redis.HGet("test", "IntField"); Assert.AreEqual(my_obj.IntField.ToString(), hget_int_result); Redis.Del("test"); }
public void TestHExists() { Redis.Del("test"); RedisGenericTest my_obj = RedisGenericTest.Create(); var hmsset_result = Redis.HMSet("test", my_obj); var hexists_result1 = Redis.HExists("test", "StringField"); Assert.IsTrue(hexists_result1); var hexists_result2 = Redis.HExists("test", "JunkField"); Assert.IsFalse(hexists_result2); Redis.Del("test"); }
public void TestHSet() { Redis.Del("test"); var obj = RedisGenericTest.Create(); Redis.HMSet("test", obj); var res_update = Redis.HSet("test", "StringField", "update"); Assert.IsFalse(res_update); var res_new = Redis.HSet("test", "NewField", "new"); Assert.IsTrue(res_new); Redis.Del("test"); }
public void TestHDel() { Redis.Del("test"); RedisGenericTest my_obj = RedisGenericTest.Create(); var hmsset_result = Redis.HMSet("test", my_obj); var hdel_result = Redis.HDel("test", "StringField", "CharField"); Assert.AreEqual(2, hdel_result); var hgetall_result = Redis.HGetAll("test"); Assert.IsFalse(hgetall_result.ContainsKey("StringField")); Assert.IsFalse(hgetall_result.ContainsKey("CharField")); Redis.Del("test"); }
public void TestHSetNx() { Redis.Del("test"); var obj = RedisGenericTest.Create(); Redis.HMSet("test", obj); var res_update = Redis.HSetNx("test", "StringField", "update"); Assert.IsFalse(res_update); var res_dict1 = Redis.HGetAll("test"); Assert.AreEqual(obj.StringField, res_dict1["StringField"]); var res_new = Redis.HSetNx("test", "NewField", "new"); Assert.IsTrue(res_new); var res_dict2 = Redis.HGetAll("test"); Assert.AreEqual("new", res_dict2["NewField"]); Redis.Del("test"); }