Beispiel #1
0
        public void TestDataIsCachingTest()
        {
            const string callType = "GetAllSportsAsync";

            _timer.FireOnce(TimeSpan.Zero);
            Thread.Sleep(500);

            var sports = _sportDataCache.GetSportsAsync(TestData.Cultures).Result;

            Assert.IsNotNull(sports, "Retrieved sports cannot be null");
            Assert.IsTrue(sports.Any(), "sports.Count() > 0");
            Assert.AreEqual(TestData.Cultures.Count, _dataRouterManager.GetCallCount(callType), $"{callType} should be called exactly {TestData.Cultures.Count} times.");
        }
        public void Init()
        {
            _variantMemoryCache   = new MemoryCache("VariantCache");
            _invariantMemoryCache = new MemoryCache("InVariantCache");
            _variantsMemoryCache  = new MemoryCache("VariantsCache");
            //force markets to be loaded
            _timer = new TestTimer(false);
            _timer.FireOnce(TimeSpan.Zero);
            var specifiers = new ReadOnlyDictionary <string, string>(new Dictionary <string, string>
            {
                { "score", "1:1" }
            });

            _cacheManager      = new CacheManager();
            _dataRouterManager = new TestDataRouterManager(_cacheManager);

            _mappingValidatorFactory = new MappingValidatorFactory();

            _timer            = new TestTimer(true);
            _variantMdCache   = new VariantMarketDescriptionCache(_variantMemoryCache, _dataRouterManager, _mappingValidatorFactory, _cacheManager);
            _inVariantMdCache = new InvariantMarketDescriptionCache(_invariantMemoryCache, _dataRouterManager, _mappingValidatorFactory, _timer, TestData.Cultures, _cacheManager);
            _variantsMdCache  = new VariantDescriptionListCache(_variantsMemoryCache, _dataRouterManager, _mappingValidatorFactory, _timer, TestData.Cultures, _cacheManager);

            _nameProvider = new NameProvider(
                new MarketCacheProvider(_inVariantMdCache, _variantMdCache, _variantsMdCache),
                new Mock <IProfileCache>().Object,
                new Mock <INameExpressionFactory>().Object,
                new Mock <ISportEvent>().Object,
                41,
                specifiers,
                ExceptionHandlingStrategy.THROW
                );
        }
Beispiel #3
0
        public void TestDataIsCaching()
        {
            // even if called several times, loads only once for all specified languages
            _timer.FireOnce(TimeSpan.Zero);
            _timer.FireOnce(TimeSpan.Zero);
            _timer.FireOnce(TimeSpan.Zero);

            var i = 0;

            while (_dataRouterManager.GetCallCount(DateSchedule) != (TestData.Cultures.Count * 3) && i < 100)
            {
                System.Threading.Thread.Sleep(100);
                i++;
            }
            Assert.IsTrue(_memoryCache.GetCount() > 0, "Nothing was cached.");
            Assert.AreEqual(ScheduleEventCount, _sportEventCache.Cache.Count(c => c.Key.Contains("match")), "cache item count is wrong");
            Assert.AreEqual(TestData.Cultures.Count * 3, _dataRouterManager.GetCallCount(DateSchedule), $"{DateSchedule} should be called exactly {TestData.Cultures.Count * 3} times.");
        }