public void Init()
        {
            _memoryCache = new MemoryCache("sportEventCache");

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

            _timer           = new TestTimer(false);
            _sportEventCache = new SportEventCache(_memoryCache,
                                                   _dataRouterManager,
                                                   new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5, ExceptionHandlingStrategy.THROW), TestData.Cultures.First(), new MemoryCache("FixtureTimestampCache")),
                                                   _timer,
                                                   TestData.Cultures3,
                                                   _cacheManager);

            var deserializer  = new Deserializer <tournamentInfoEndpoint>();
            var dataFetcher   = new TestDataFetcher();
            var mapperFactory = new TournamentInfoMapperFactory();

            var tourDataProvider = new DataProvider <tournamentInfoEndpoint, TournamentInfoDTO>(TestData.RestXmlPath + TourInfoXml, dataFetcher, deserializer, mapperFactory);

            _tourApiData = deserializer.Deserialize(dataFetcher.GetData(new Uri(string.Format(TestData.RestXmlPath + TourInfoXml))));
            _tourDtoData = tourDataProvider.GetDataAsync("", "en").Result;
            _tourCiData  = (TournamentInfoCI)_sportEventCache.GetEventCacheItem(URN.Parse("sr:tournament:40"));

            var seasonDataProvider = new DataProvider <tournamentInfoEndpoint, TournamentInfoDTO>(TestData.RestXmlPath + SeasonInfoXml, dataFetcher, deserializer, mapperFactory);

            _seasonApiData = deserializer.Deserialize(dataFetcher.GetData(new Uri(string.Format(TestData.RestXmlPath + SeasonInfoXml))));
            _seasonDtoData = seasonDataProvider.GetDataAsync("", "en").Result;
            _seasonCiData  = (TournamentInfoCI)_sportEventCache.GetEventCacheItem(URN.Parse("sr:season:80242"));
        }
        public static tournamentInfoEndpoint GeTournamentInfoEndpoint(int id = 0, int subItemCount = 0)
        {
            if (subItemCount == 0)
            {
                subItemCount = SR.I(20);
            }

            var groups = new List <tournamentGroup>();

            for (var j = 0; j < subItemCount; j++)
            {
                groups.Add(GetTournamentGroup());
            }

            var msg = new tournamentInfoEndpoint
            {
                tournament            = GetTournamentExtendedList(10).First(),
                competitors           = GetTournamentExtendedList(10).First().competitors,
                generated_at          = DateTime.Today,
                generated_atSpecified = true,
                groups = groups.ToArray(),
                round  = GetMatchRound(),
                season = GetSeasonExtended(),
                season_coverage_info = GetSeasonCoverageInfo()
            };

            return(msg);
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicTournamentDTO"/> class.
        /// </summary>
        /// <param name="tournamentInfo">The <see cref="tournament"/> used for creating instance</param>
        internal BasicTournamentDTO(tournamentInfoEndpoint tournamentInfo)
            : base(new sportEvent
        {
            id                     = tournamentInfo.tournament.id,
            name                   = tournamentInfo.tournament.name,
            scheduled              = tournamentInfo.tournament.scheduled,
            scheduledSpecified     = tournamentInfo.tournament.scheduledSpecified,
            scheduled_end          = tournamentInfo.tournament.scheduled_end,
            scheduled_endSpecified = tournamentInfo.tournament.scheduled_endSpecified,
            tournament             = tournamentInfo.tournament,
            type                   = null
        })
        {
            Guard.Argument(tournamentInfo, nameof(tournamentInfo)).NotNull();

            TournamentCoverage = new TournamentCoverageDTO(tournamentInfo.coverage_info);
            Category           = tournamentInfo.tournament.category == null
                ? null
                : URN.Parse(tournamentInfo.tournament.category.id);
            Competitors = tournamentInfo.competitors.Select(s => new CompetitorDTO(s));
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicTournamentDTO"/> class.
        /// </summary>
        /// <param name="tournamentInfo">The <see cref="tournament"/> used for creating instance</param>
        internal BasicTournamentDTO(tournamentInfoEndpoint tournamentInfo)
            : base(new sportEvent
        {
            id                     = tournamentInfo.tournament.id,
            name                   = tournamentInfo.tournament.name,
            scheduled              = tournamentInfo.tournament.scheduled,
            scheduledSpecified     = tournamentInfo.tournament.scheduledSpecified,
            scheduled_end          = tournamentInfo.tournament.scheduled_end,
            scheduled_endSpecified = tournamentInfo.tournament.scheduled_endSpecified,
            tournament             = tournamentInfo.tournament,
            type                   = null
        })
        {
            Contract.Requires(tournamentInfo != null);

            TournamentCoverage = new TournamentCoverageDTO(tournamentInfo.coverage_info);
            Category           = tournamentInfo.tournament.category == null
                ? null
                : URN.Parse(tournamentInfo.tournament.category.id);
            Competitors = tournamentInfo.competitors.Select(s => new CompetitorDTO(s));
        }
Exemple #5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="TournamentInfoMapper" /> class
        /// </summary>
        /// <param name="data">A <see cref="tournamentInfoEndpoint" /> instance containing tournament detail information</param>
        internal TournamentInfoMapper(tournamentInfoEndpoint data)
        {
            Contract.Requires(data != null);

            _data = data;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventSummaryMapper"/> class.
        /// </summary>
        /// <param name="tournamentInfoData">A <see cref="tournamentInfoEndpoint"/> containing tournament data</param>
        internal SportEventSummaryMapper(tournamentInfoEndpoint tournamentInfoData)
        {
            Guard.Argument(tournamentInfoData, nameof(tournamentInfoData)).NotNull();

            _tournamentInfoData = tournamentInfoData;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TournamentInfoDTO"/> class
        /// </summary>
        /// <param name="tournament">A <see cref="tournament"/> containing detailed tournament info</param>
        internal TournamentInfoDTO(tournamentInfoEndpoint tournament)
            : base(new sportEvent
        {
            id   = tournament.tournament.id,
            name = tournament.tournament.name,
            scheduledSpecified     = IsTournamentScheduleSpecified(tournament.tournament, true) || tournament.tournament.current_season != null,
            scheduled              = GetExtendedTournamentSchedule(tournament.tournament, true),
            scheduled_endSpecified = IsTournamentScheduleSpecified(tournament.tournament, false) || tournament.tournament.current_season != null,
            scheduled_end          = GetExtendedTournamentSchedule(tournament.tournament, false),
            tournament             = tournament.tournament
        })
        {
            TournamentCoverage = tournament.coverage_info == null
                ? null
                : new TournamentCoverageDTO(tournament.coverage_info);

            Category = tournament.tournament.category == null
                ? null
                : new CategorySummaryDTO(tournament.tournament.category);

            Sport = tournament.tournament.sport == null
                ? null
                : new SportEntityDTO(tournament.tournament.sport.id, tournament.tournament.sport.name);

            Competitors = tournament.competitors != null
                ? new ReadOnlyCollection <CompetitorDTO>(tournament.competitors.Select(c => new CompetitorDTO(c)).ToList())
                : tournament.tournament?.competitors == null // used for stage events
                    ? null
                    : new ReadOnlyCollection <CompetitorDTO>(tournament.tournament.competitors.Select(c => new CompetitorDTO(c)).ToList());

            CurrentSeason = tournament.tournament.current_season == null
                ? null
                : new CurrentSeasonInfoDTO(tournament.tournament.current_season);

            Season = tournament.season == null
                ? null
                : new CurrentSeasonInfoDTO(tournament.season);

            SeasonCoverage = tournament.season_coverage_info == null
                ? null
                : new SeasonCoverageDTO(tournament.season_coverage_info);

            Groups = tournament.groups == null
                ? null
                : new ReadOnlyCollection <GroupDTO>(tournament.groups.Select(g => new GroupDTO(g)).ToList());

            Schedule = null;

            CurrentRound = tournament.round == null
                ? null
                : new RoundDTO(tournament.round);

            Year = tournament.tournament?.current_season == null
                ? tournament.season?.year
                : tournament.tournament.current_season.year;

            TournamentInfo = null;

            if (tournament.tournament?.category != null)
            {
                var sportEvent = new sportEvent
                {
                    id   = tournament.tournament.id,
                    name = tournament.tournament.name,
                    scheduledSpecified     = IsTournamentScheduleSpecified(tournament.tournament, true) || tournament.tournament.current_season != null,
                    scheduled              = GetExtendedTournamentSchedule(tournament.tournament, true),
                    scheduled_endSpecified = IsTournamentScheduleSpecified(tournament.tournament, false) || tournament.tournament.current_season != null,
                    scheduled_end          = GetExtendedTournamentSchedule(tournament.tournament, false),
                    tournament             = tournament.tournament
                };
                TournamentInfo = new TournamentInfoDTO(sportEvent)
                {
                    Category      = new CategorySummaryDTO(tournament.tournament.category.id, tournament.tournament.category.name, tournament.tournament.category.country_code),
                    CurrentSeason = tournament.tournament.current_season == null
                        ? null
                        : new CurrentSeasonInfoDTO(tournament.tournament.current_season)
                };
            }

            GeneratedAt = tournament.generated_atSpecified ? tournament.generated_at : (DateTime?)null;

            ExhibitionGames = tournament.tournament.exhibition_gamesSpecified
                ? tournament.tournament.exhibition_games
                : (bool?)null;
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventSummaryMapper"/> class.
        /// </summary>
        /// <param name="tournamentInfoData">A <see cref="tournamentInfoEndpoint"/> containing tournament data</param>
        internal SportEventSummaryMapper(tournamentInfoEndpoint tournamentInfoData)
        {
            Contract.Requires(tournamentInfoData != null);

            _tournamentInfoData = tournamentInfoData;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TournamentInfoMapper"/> class
        /// </summary>
        /// <param name="data">A <see cref="tournamentInfoEndpoint"/> instance containing tournament detail information</param>
        internal TournamentInfoMapper(tournamentInfoEndpoint data)
        {
            Guard.Argument(data, nameof(data)).NotNull();

            _data = data;
        }