public void DeleteResult() { using (dynamic client = new RedisClient()) { client.set("delete", "some val"); // give it a value initially bool first = client.del("delete"); // was deleted: true bool second = client.del("delete"); // no longer existed: false Assert.IsTrue(first); Assert.IsFalse(second); } }
public void GetSet() { using (dynamic client = new RedisClient()) { client.del("getset"); // wipe client.set("getset", "def"); // assign string val = client.get("getset"); // fetch Assert.AreEqual("def", val); } }
public void Counters() { using (dynamic client = new RedisClient()) { client.del("counter"); // note: missing counts as 0 int a = client.incr("counter"); // 0+1: should be 1 int b = client.incrby("counter", 5); // 1+5, should be 6 int c = client.decr("counter"); // 6-1: should be 5 Assert.AreEqual(1, a, "a"); Assert.AreEqual(6, b, "b"); Assert.AreEqual(5, c, "c"); } }
public void Lists() { using (dynamic client = new RedisClient()) { client.del("list"); client.rpush("list", "item 1"); client.rpush("list", "item 2"); string a = client.lpop("list"); string b = client.lpop("list"); string c = client.lpop("list"); client.rpush("list", "item 3"); string d = client.lpop("list"); Assert.AreEqual(a, "item 1"); Assert.AreEqual(b, "item 2"); Assert.IsNull(c); Assert.AreEqual(d, "item 3"); } }