public void Remove_NoSuppression( )
        {
            for (int i = 0; i < 1000; i++)
            {
                const string cacheName = "My Precious";

                Tuple <long, string> [] testData =
                {
                    new Tuple <long, string>(144, "foo"),
                    new Tuple <long, string>(96,  "bar")
                };

                string value;

                IDistributedMemoryManager memoryManager = Factory.DistributedMemoryManager;

                using (RedisPubSubCache <long, string> redisPubSubCache1 = new RedisPubSubCache <long, string>(new DictionaryCache <long, string>( ), cacheName, memoryManager))
                    using (RedisPubSubCache <long, string> redisPubSubCache2 = new RedisPubSubCache <long, string>(new DictionaryCache <long, string>( ), cacheName, memoryManager))
                    {
                        foreach (Tuple <long, string> testDatum in testData)
                        {
                            redisPubSubCache1.Add(testDatum.Item1, testDatum.Item2);
                            redisPubSubCache2.Add(testDatum.Item1, testDatum.Item2);
                        }

                        CountdownEvent evt = new CountdownEvent(1);

                        EventHandler <MessageEventArgs <RedisPubSubCacheMessage <long> > > handler = (sender, message) =>
                        {
                            evt.Signal( );
                        };

                        redisPubSubCache2.Channel.MessageReceived += handler;

                        redisPubSubCache1.Remove(testData [0].Item1);

                        // Wait for message
                        evt.Wait(DefaultRedisWaitTime);

                        redisPubSubCache2.Channel.MessageReceived -= handler;

                        Assert.That(redisPubSubCache1.TryGetValue(testData [0].Item1, out value), Is.False, "Item not removed from cache 1");
                        Assert.That(redisPubSubCache2.TryGetValue(testData [0].Item1, out value), Is.False, "Item not removed from cache 2");
                        Assert.That(redisPubSubCache1.TryGetValue(testData [1].Item1, out value), Is.True, "Item 2 removed from cache 1");
                        Assert.That(value, Is.EqualTo(testData [1].Item2), "Item 2 incorrect value in cache 1");
                        Assert.That(redisPubSubCache2.TryGetValue(testData [1].Item1, out value), Is.True, "Item 2 removed from cache 2");
                        Assert.That(value, Is.EqualTo(testData [1].Item2), "Item 2 incorrect value in cache 2");
                    }
            }
        }
        public void Clear_Supression()
        {
            const string cacheName = "My Precious";

            Tuple <long, string>[] testData =
            {
                new Tuple <long, string>(26,  "foo"),
                new Tuple <long, string>(986, "bar")
            };
            string value;

            IDistributedMemoryManager memoryManager = Factory.DistributedMemoryManager;

            using (RedisPubSubCache <long, string> redisPubSubCache1 = new RedisPubSubCache <long, string>(
                       new DictionaryCache <long, string>( ), cacheName, memoryManager))
                using (RedisPubSubCache <long, string> redisPubSubCache2 = new RedisPubSubCache <long, string>(
                           new DictionaryCache <long, string>( ), cacheName, memoryManager))
                {
                    foreach (Tuple <long, string> testDatum in testData)
                    {
                        redisPubSubCache1.Add(testDatum.Item1, testDatum.Item2);
                        redisPubSubCache2.Add(testDatum.Item1, testDatum.Item2);
                    }

                    using (new RedisCacheMessageSuppressionContext(cacheName))
                    {
                        redisPubSubCache1.Clear();
                    }

                    Assert.That(redisPubSubCache1.TryGetValue(testData[0].Item1, out value), Is.False, "Item 1 not removed from cache 1");
                    Assert.That(redisPubSubCache2.TryGetValue(testData[0].Item1, out value), Is.True, "Item 1 removed from cache 2");
                    Assert.That(redisPubSubCache1.TryGetValue(testData[1].Item1, out value), Is.False, "Item 2 not removed from cache 1");
                    Assert.That(redisPubSubCache2.TryGetValue(testData[1].Item1, out value), Is.True, "Item 2 removed from cache 2");
                    Assert.That(redisPubSubCache1, Is.Empty, "Cache 1 not empty");
                    Assert.That(redisPubSubCache2, Is.Not.Empty, "Cache 2 not empty");
                }
        }
        public void Remove_Suppression()
        {
            const string cacheName = "My Precious";

            Tuple <long, string>[] testData =
            {
                new Tuple <long, string>(144, "foo"),
                new Tuple <long, string>(96,  "bar")
            };
            string value;

            IDistributedMemoryManager memoryManager = Factory.DistributedMemoryManager;

            using (RedisPubSubCache <long, string> redisPubSubCache1 = new RedisPubSubCache <long, string>(
                       new DictionaryCache <long, string>( ), cacheName, memoryManager))
                using (RedisPubSubCache <long, string> redisPubSubCache2 = new RedisPubSubCache <long, string>(
                           new DictionaryCache <long, string>( ), cacheName, memoryManager))
                {
                    foreach (Tuple <long, string> testDatum in testData)
                    {
                        redisPubSubCache1.Add(testDatum.Item1, testDatum.Item2);
                        redisPubSubCache2.Add(testDatum.Item1, testDatum.Item2);
                    }

                    using (new RedisCacheMessageSuppressionContext(cacheName))
                    {
                        redisPubSubCache1.Remove(testData[0].Item1);
                    }

                    Assert.That(redisPubSubCache1.TryGetValue(testData[0].Item1, out value), Is.False, "Item not removed from cache 1");
                    Assert.That(redisPubSubCache2.TryGetValue(testData[0].Item1, out value), Is.True, "Item removed from cache 2");
                    Assert.That(redisPubSubCache1.TryGetValue(testData[1].Item1, out value), Is.True, "Item 2 removed from cache 1");
                    Assert.That(value, Is.EqualTo(testData[1].Item2), "Item 2 incorrect value in cache 1");
                    Assert.That(redisPubSubCache2.TryGetValue(testData[1].Item1, out value), Is.True, "Item 2 removed from cache 2");
                    Assert.That(value, Is.EqualTo(testData[1].Item2), "Item 2 incorrect value in cache 2");
                }
        }