public async Task ShouldSubscribeToEventFeed() { var eventIdProvider = new InMemoryEventIdProvider(); var serializer = new JsonNetSerializer(); var eventSerializer = new EventSerializer(serializer); var eventCache = new InMemoryEventCache(eventIdProvider, eventSerializer); var brokerConfiguration = new BrokerageServiceConfiguration() { HeartbeatEndpoint = HeartbeatEndpoint, StateOftheWorldEndpoint = StateOfTheWorldEndpoint, ToSubscribersEndpoint = ToSubscribersEndpoint, ToPublisherEndpoint = ToPublishersEndpoint }; var router = new BrokerageService(brokerConfiguration, eventCache, serializer); var marketConfiguration = new ProducerConfiguration() { RouterEndpoint = ToPublishersEndpoint, HearbeatEndpoint = HeartbeatEndpoint }; var market1 = new Market("FxConnect", marketConfiguration, eventSerializer, TimeSpan.FromMilliseconds(750)); var market2 = new Market("Harmony", marketConfiguration, eventSerializer, TimeSpan.FromMilliseconds(750)); await router.Run(); await market1.Run(); await market2.Run(); //create an event cache await Task.Delay(2000); //Assert.Greater(router.Cache.Count(), 0); var cacheConfiguration = new DynamicCacheConfiguration(ToSubscribersEndpoint, StateOfTheWorldEndpoint, HeartbeatEndpoint); var cache = new DynamicCache <string, CurrencyPair>(cacheConfiguration, eventSerializer); var counter = 0; var cleanup = cache.OnItemChanged() .Connect() .Subscribe(_ => { counter++; }); await cache.Run(); await Task.Delay(2000); // Assert.AreEqual(router.Cache.Count(), counter); Assert.AreEqual(cache.GetItems().SelectMany(item => item.AppliedEvents).Count(), counter); //fxconnext & harmony Assert.AreEqual(2, cache.GetItems() .SelectMany(item => item.AppliedEvents) .Cast <ChangeCcyPairPrice>() .Select(ev => ev.Market) .Distinct() .Count()); cleanup.Dispose(); await Task.WhenAll(new[] { router.Destroy(), market1.Destroy(), market2.Destroy(), cache.Destroy() }); }