public void MergeAction(RedisPubSubCacheMessage <int> existingMessage, RedisPubSubCacheMessage <int> newMessage,
                                RedisPubSubCacheMessage <int> expectedMergedMessage)
        {
            RedisPubSubCacheHelpers.MergeAction(existingMessage, newMessage);

            Assert.That(existingMessage, Is.EqualTo(expectedMergedMessage));
        }
 public void MergeAction_NullNewMessage()
 {
     Assert.That(
         () => RedisPubSubCacheHelpers.MergeAction(new RedisPubSubCacheMessage <int>(RedisPubSubCacheMessageAction.Remove), null),
         Throws.TypeOf <ArgumentNullException>().And.Property("ParamName").EqualTo("newMessage")
         );
 }
 public void GetChannelName_Null()
 {
     Assert.That(
         () => RedisPubSubCacheHelpers.GetChannelName(null),
         Throws.TypeOf <ArgumentNullException>().And.Property("ParamName").EqualTo("cacheName")
         );
 }
 public void GetChannelName(string cacheName, string expectedCacheName)
 {
     Assert.That(
         RedisPubSubCacheHelpers.GetChannelName(cacheName),
         Is.EqualTo(expectedCacheName)
         );
 }
        public void Ctor_Connected()
        {
            MockRepository mockRepository;
            const string   name = "Name";
            DictionaryCache <long, string>   dictionaryCache;
            Mock <IDistributedMemoryManager> memoryManagerMock;
            Mock <IChannel <RedisPubSubCacheMessage <long> > > channelMock;

            mockRepository  = new MockRepository(MockBehavior.Strict);
            dictionaryCache = new DictionaryCache <long, string>();
            channelMock     = mockRepository.Create <IChannel <RedisPubSubCacheMessage <long> > >();
            channelMock.Setup(c => c.Subscribe());
            channelMock.Setup(c => c.Dispose());
            memoryManagerMock = mockRepository.Create <IDistributedMemoryManager>();
            memoryManagerMock.Setup(mm => mm.IsConnected).Returns(true);
            memoryManagerMock.Setup(mm => mm.GetChannel <RedisPubSubCacheMessage <long> >(
                                        RedisPubSubCacheHelpers.GetChannelName(name))).Returns(channelMock.Object);

            using (RedisPubSubCache <long, string> redisCache =
                       new RedisPubSubCache <long, string>(dictionaryCache, name, memoryManagerMock.Object))
            {
                Assert.That(redisCache, Has.Property("Name").EqualTo(name));
                Assert.That(redisCache, Has.Property("InnerCache").SameAs(dictionaryCache));
                Assert.That(redisCache.MemoryManager, Is.SameAs(memoryManagerMock.Object));
                Assert.That(redisCache.Channel, Is.SameAs(channelMock.Object));
            }

            mockRepository.VerifyAll();
        }