public void MultipleCompetitorsRequestForOneShouldNotInvokeApiRequestsDelayed() { const string callType = "GetCompetitorAsync"; Assert.IsNotNull(_memoryCache); Assert.IsTrue(!_memoryCache.Any()); var cultures = new List <CultureInfo> { TestData.Culture }; Assert.AreEqual(0, _dataRouterManager.GetCallCount(callType), $"{callType} should be called 0 times."); _dataRouterManager.AddDelay(TimeSpan.FromSeconds(5), true, 100); var cid = StaticRandom.I1000; for (var i = 0; i < 10; i++) { Debug.Print(i.ToString()); var competitor = _profileCache.GetCompetitorProfileAsync(CreateCompetitorUrn(cid), cultures).Result; Assert.IsNotNull(competitor); } Assert.AreEqual(1, _memoryCache.Count(s => s.Key.Contains(":competitor:"))); Assert.AreEqual(cultures.Count, _dataRouterManager.GetCallCount(callType), $"{callType} should be called {cultures.Count} times."); }
//[TestMethod, Timeout(300000)] public async Task SportEventCacheSemiWithDelaySequentialTest() { var stopWatch = Stopwatch.StartNew(); Assert.AreEqual(0, _memoryCache.Count()); var i = 1000; var culture = TestData.Cultures4[StaticRandom.I(4)]; _dataRouterManager.AddDelay(TimeSpan.FromMilliseconds(1000), true, 30); while (i > 0) { var matchId = URN.Parse($"sr:match:1{StaticRandom.I100}"); i--; var ci = await GetMatchCacheItemAsync(matchId, culture, stopWatch, i).ConfigureAwait(false); Assert.IsNotNull(ci); Assert.AreEqual(matchId, ci.Id); } Assert.IsTrue(_memoryCache.Count() > 50); Assert.IsTrue(_memoryCache.Count() < 100); }