public void CanHandleCommands() { RedisServiceFactory.Register<IRedisCommandHandler, TestCommandHandler>(); TestCommandHandler cmdHandler = (TestCommandHandler)RedisServiceFactory.CommandHandlers.First(); bool onExecutingDone = false; bool onExecutedDone = false; RedisKey[] testKeys = new RedisKey[] { "test" }; RedisValue[] testValues = new RedisValue[] { "test value" }; object testResult = (RedisValue)"hello world"; cmdHandler.onExecuting = (command, involvedKeys, involvedValues) => { Assert.AreEqual(RedisCommand.SET, command); Assert.AreEqual(1, testKeys.Intersect(involvedKeys).Count()); Assert.AreEqual(1, testValues.Intersect(involvedValues).Count()); onExecutingDone = true; }; cmdHandler.onExecuted = (RedisCommand command, ref object result, RedisKey[] involvedKeys) => { Assert.AreEqual(RedisCommand.HMSET, command); Assert.AreEqual(1, testKeys.Intersect(involvedKeys).Count()); Assert.AreEqual(testResult, result); onExecutedDone = true; }; RedisServiceFactory.CommandHandlers.ExecuteBeforeHandlers(RedisCommand.SET, new RedisKey[] { "test" }, new RedisValue[] { "test value" }); RedisServiceFactory.CommandHandlers.ExecuteAfterHandlers(RedisCommand.HMSET, new RedisKey[] { "test" }, ref testResult); Assert.IsTrue(onExecutingDone); Assert.IsTrue(onExecutedDone); }