public void updates_cached_routes()
        {
            var cache = new SubscriptionCache(new ChannelGraph(), new ITransport[] { new InMemoryTransport(), });

            var subscriptions1 = new[]
            {
                ObjectMother.ExistingSubscription(),
                ObjectMother.ExistingSubscription()
            };

            subscriptions1[0].MessageType = typeof(string).FullName;
            subscriptions1[1].MessageType = typeof(int).FullName;

            var subscriptions2 = new[] { ObjectMother.ExistingSubscription() };

            subscriptions2[0].MessageType = typeof(int).FullName;

            cache.LoadSubscriptions(subscriptions1);
            cache.FindDestinationChannels(new Envelope {
                Message = "Foo"
            });
            cache.FindDestinationChannels(new Envelope {
                Message = 42
            });
            cache.CachedRoutes.ContainsKey(typeof(string)).ShouldBeTrue();
            cache.CachedRoutes.ContainsKey(typeof(int)).ShouldBeTrue();

            cache.LoadSubscriptions(subscriptions2);
            cache.CachedRoutes.ContainsKey(typeof(string)).ShouldBeFalse();
            cache.CachedRoutes.ContainsKey(typeof(int)).ShouldBeTrue();
        }
        public void clears_volatile_nodes()
        {
            var envelope     = ObjectMother.EnvelopeWithMessage();
            var subscription = ObjectMother.ExistingSubscription();

            subscription.MessageType = envelope.Message.GetType().FullName;

            _cache.LoadSubscriptions(new[] { subscription });
            IList <ChannelNode> channels = _cache.FindDestinationChannels(envelope).ToList();

            channels.ShouldNotBeEmpty();
            var oldNode = channels.Single();

            _cache.ClearAll();
            _cache.LoadSubscriptions(new[] { subscription });
            channels = _cache.FindDestinationChannels(envelope).ToList();
            channels.ShouldNotBeEmpty();
            channels.ShouldNotContain(oldNode);
        }