public void Init()
        {
            var configInternal = new SdkConfigurationInternal(new SdkConfiguration("username", "password", "host", null, true, "sslServerName", 1, 0, 0, "EUR", null, "aaa"), null);

            _cultures = new List <CultureInfo> {
                new CultureInfo("en")
            };

            var uri = new Uri(@"https://api.betradar.com/v1/descriptions/en/markets.xml?include_mappings=true");

            _mockDataFetcher = new Mock <DataFetcherHelper>();
            _mockDataFetcher.Setup(p => p.GetDataAsync(It.IsAny <Uri>())).Returns(new DataFetcherHelper(BuilderFactoryHelper.UriReplacements).GetDataAsync(uri));

            _deserializer = new Deserializer <market_descriptions>();
            _mapper       = new MarketDescriptionsMapperFactory();

            _dataProvider = new DataProvider <market_descriptions, IEnumerable <MarketDescriptionDTO> >(
                uri.AbsoluteUri,
                _mockDataFetcher.Object,
                _mockDataFetcher.Object,
                _deserializer,
                _mapper);

            _marketDescriptionCache = new MarketDescriptionCache(new MemoryCache("InvariantMarketDescriptionCache"),
                                                                 _dataProvider,
                                                                 _cultures,
                                                                 configInternal.AccessToken,
                                                                 TimeSpan.FromHours(4),
                                                                 new CacheItemPolicy {
                SlidingExpiration = TimeSpan.FromDays(1)
            });
        }
        public static ISelectionBuilder Create()
        {
            //TODO: prone to fail in web app
            var configInternal = new SdkConfigurationInternal(new SdkConfiguration(SdkConfigurationSection.GetSection()), null);
            var value          = new Random((int)DateTime.Now.Ticks).Next();
            var dataFetcher    = new LogHttpDataFetcher(new HttpClient(),
                                                        configInternal.AccessToken,
                                                        new IncrementalSequenceGenerator(value, long.MaxValue),
                                                        3,
                                                        12);
            var deserializer = new Deserializer <market_descriptions>();
            var mapper       = new MarketDescriptionsMapperFactory();

            var dataProvider = new DataProvider <market_descriptions, IEnumerable <MarketDescriptionDTO> >(
                configInternal.ApiHost + "/v1/descriptions/{0}/markets.xml?include_mappings=true",
                dataFetcher,
                dataFetcher,
                deserializer,
                mapper);

            var marketDescriptionCache = new MarketDescriptionCache(new MemoryCache("InvariantMarketDescriptionCache"),
                                                                    dataProvider,
                                                                    new [] { new CultureInfo("en") },
                                                                    configInternal.AccessToken,
                                                                    TimeSpan.FromHours(4),
                                                                    new CacheItemPolicy {
                SlidingExpiration = TimeSpan.FromDays(1)
            });
            var marketDescriptionProvider = new MarketDescriptionProvider(marketDescriptionCache, new[] { new CultureInfo("en") });

            return(new SelectionBuilder(marketDescriptionProvider, configInternal, false));
        }
Exemple #3
0
        public async Task GetMarketDescriptionsAsync(CultureInfo culture)
        {
            RecordCall("GetMarketDescriptionsAsync");
            var filePath         = GetFile("invariant_market_descriptions.{culture}.xml", culture);
            var restDeserializer = new Deserializer <market_descriptions>();
            var mapper           = new MarketDescriptionsMapperFactory();
            var stream           = FileHelper.OpenFile(filePath);
            var result           = mapper.CreateMapper(restDeserializer.Deserialize(stream)).Map();

            if (result != null)
            {
                await _cacheManager.SaveDtoAsync(URN.Parse("sr:markets:" + result.Items?.Count()), result, culture, DtoType.MarketDescriptionList, null).ConfigureAwait(false);
            }
        }
        public static void Init(TestContext context)
        {
            var deserializer  = new Deserializer <market_descriptions>();
            var dataFetcher   = new TestDataFetcher();
            var mapperFactory = new MarketDescriptionsMapperFactory();

            var dataProvider = new DataProvider <market_descriptions, EntityList <MarketDescriptionDTO> >(
                TestData.RestXmlPath + InputXml,
                dataFetcher,
                deserializer,
                mapperFactory);

            _entity = dataProvider.GetDataAsync("", "en").Result;
        }