private void MappingConditionsTest(MatchDTO dto, matchSummaryEndpoint record)
        {
            if (record.sport_event_conditions == null)
            {
                return;
            }

            _assertHelper.AreEqual(() => dto.Conditions.Attendance, record.sport_event_conditions.attendance);
            _assertHelper.AreEqual(() => dto.Conditions.EventMode, record.sport_event_conditions.match_mode);

            _assertHelper.AreEqual(() => dto.Conditions.Referee.Id.ToString(), record.sport_event_conditions.referee.id);
            _assertHelper.AreEqual(() => dto.Conditions.Referee.Name, record.sport_event_conditions.referee.name);
            _assertHelper.AreEqual(() => dto.Conditions.Referee.Nationality, record.sport_event_conditions.referee.nationality);
            //_assertHelper.AreEqual(() => dto.Conditions.Referee.Value, record.sport_event_conditions.referee.Value);

            //_assertHelper.AreEqual(() => null, record.sport_event_conditions.weather_info.Value);
            _assertHelper.AreEqual(() => dto.Conditions.WeatherInfo.Pitch, record.sport_event_conditions.weather_info.pitch);
            _assertHelper.AreEqual(() => dto.Conditions.WeatherInfo.WeatherConditions, record.sport_event_conditions.weather_info.weather_conditions);
            _assertHelper.AreEqual(() => dto.Conditions.WeatherInfo.Wind, record.sport_event_conditions.weather_info.wind);
            _assertHelper.AreEqual(() => dto.Conditions.WeatherInfo.WindAdvantage, record.sport_event_conditions.weather_info.wind_advantage);
            _assertHelper.AreEqual(() => dto.Conditions.WeatherInfo.TemperatureCelsius,
                                   record.sport_event_conditions.weather_info.temperature_celsiusSpecified
                                       ? (int?)record.sport_event_conditions.weather_info.temperature_celsius
                                       : null);

            MappingVenueTest(dto, record);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionDTO"/> class
        /// </summary>
        /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param>
        internal CompetitionDTO(matchSummaryEndpoint matchSummary)
            : this(matchSummary.sport_event)
        {
            Guard.Argument(matchSummary, nameof(matchSummary)).NotNull();

            Conditions = matchSummary.sport_event_conditions == null
                ? Conditions
                : new SportEventConditionsDTO(matchSummary.sport_event_conditions);

            SportEventStatus = matchSummary.sport_event_status == null
                ? null
                : new SportEventStatusDTO(matchSummary.sport_event_status, matchSummary.statistics, HomeAwayCompetitors);

            Venue = matchSummary.sport_event_conditions?.venue == null
                ? Venue
                : new VenueDTO(matchSummary.sport_event_conditions.venue);

            if (Venue == null && matchSummary.venue != null)
            {
                Venue = new VenueDTO(matchSummary.venue);
            }
            GeneratedAt = matchSummary.generated_atSpecified
                              ? matchSummary.generated_at.ToLocalTime()
                              : (DateTime?)null;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchDTO"/> class
        /// </summary>
        /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param>
        internal MatchDTO(matchSummaryEndpoint matchSummary)
            : base(matchSummary)
        {
            Guard.Argument(matchSummary, nameof(matchSummary)).NotNull();

            if (matchSummary.sport_event.season != null)
            {
                Guard.Argument(matchSummary.sport_event.season.id, nameof(matchSummary.sport_event.season.id)).NotNull().NotEmpty();
                Guard.Argument(matchSummary.sport_event.season.name, nameof(matchSummary.sport_event.season.name)).NotNull().NotEmpty();
                Season = new SeasonDTO(matchSummary.sport_event.season);
            }
            if (matchSummary.sport_event.tournament_round != null)
            {
                Round = new RoundDTO(matchSummary.sport_event.tournament_round);
            }
            if (matchSummary.sport_event.tournament != null)
            {
                Guard.Argument(matchSummary.sport_event.tournament.id, nameof(matchSummary.sport_event.tournament.id)).NotNull().NotEmpty();
                Guard.Argument(matchSummary.sport_event.tournament.name, nameof(matchSummary.sport_event.tournament.name)).NotNull().NotEmpty();
                Tournament = new TournamentDTO(matchSummary.sport_event.tournament);
            }
            if (matchSummary.coverage_info != null)
            {
                Coverage = new CoverageInfoDTO(matchSummary.coverage_info);
            }
        }
 private void MappingTournamentRoundTest(MatchDTO dto, matchSummaryEndpoint record)
 {
     _assertHelper.AreEqual(() => dto.Round.Name, record.sport_event.tournament_round.name);
     _assertHelper.AreEqual(() => dto.Round.Type, record.sport_event.tournament_round.type);
     _assertHelper.AreEqual(() => dto.Round.CupRoundMatchNumber, record.sport_event.tournament_round.cup_round_match_numberSpecified ? (int?)record.sport_event.tournament_round.cup_round_match_number : null);
     _assertHelper.AreEqual(() => dto.Round.CupRoundMatches, record.sport_event.tournament_round.cup_round_matchesSpecified ? (int?)record.sport_event.tournament_round.cup_round_matches : null);
     _assertHelper.AreEqual(() => dto.Round.Number, record.sport_event.tournament_round.numberSpecified ? (int?)record.sport_event.tournament_round.number : null);
 }
 private void MappingTournamentTest(MatchDTO dto, matchSummaryEndpoint record)
 {
     _assertHelper.AreEqual(() => dto.Tournament.Id.ToString(), record.sport_event.tournament.id);
     _assertHelper.AreEqual(() => dto.Tournament.Name, record.sport_event.tournament.name);
     _assertHelper.AreEqual(() => dto.Tournament.Sport.Id.ToString(), record.sport_event.tournament.sport.id);
     _assertHelper.AreEqual(() => dto.Tournament.Sport.Name, record.sport_event.tournament.sport.name);
     _assertHelper.AreEqual(() => dto.Tournament.Category.Id.ToString(), record.sport_event.tournament.category.id);
     _assertHelper.AreEqual(() => dto.Tournament.Category.Name, record.sport_event.tournament.category.name);
 }
        public void Init()
        {
            _record = Deserializer.Deserialize(FileHelper.OpenFile(TestData.RestXmlPath, InputXml));
            _entity = new MatchSummaryMapperFactory().CreateMapper(_record).Map();

            _recordFull = Deserializer.Deserialize(FileHelper.OpenFile(TestData.RestXmlPath, InputFullXml));
            _entityFull = new MatchSummaryMapperFactory().CreateMapper(_recordFull).Map();

            _assertHelper = new AssertHelper(_entity);
        }
        private void MappingVenueTest(MatchDTO dto, matchSummaryEndpoint record)
        {
            if (record.sport_event_conditions?.venue == null)
            {
                return;
            }

            _assertHelper.AreEqual(() => dto.Venue.Id.ToString(), record.sport_event_conditions.venue.id);
            _assertHelper.AreEqual(() => dto.Venue.Name, record.sport_event_conditions.venue.name);
            _assertHelper.AreEqual(() => dto.Venue.City, record.sport_event_conditions.venue.city_name);
            _assertHelper.AreEqual(() => dto.Venue.Coordinates, record.sport_event_conditions.venue.map_coordinates);
            _assertHelper.AreEqual(() => dto.Venue.Country, record.sport_event_conditions.venue.country_name);
            _assertHelper.AreEqual(() => dto.Venue.Capacity, record.sport_event_conditions.venue.capacitySpecified ? (int?)record.sport_event_conditions.venue.capacity : null);
        }
        private void MappingCompetitorsTest(MatchDTO dto, matchSummaryEndpoint record)
        {
            //_assertHelper.AreEqual(() => dto.Competitors.Count().ToString(), record.sport_event.competitors.Length.ToString());
            Assert.AreEqual(dto.Competitors.Count(), record.sport_event.competitors.Length);
            foreach (var c in record.sport_event.competitors)
            {
                var m = dto.Competitors.FirstOrDefault(x => x.Id.ToString() == c.id);
                Assert.IsNotNull(m, $"Missing ITeamCompetitor with id: {c.id}.");
                _assertHelper.AreEqual(() => m.Qualifier, c.qualifier);
                if (c.divisionSpecified)
                {
                    _assertHelper.AreEqual(() => m.Division.Value, c.division);
                }
                else
                {
                    _assertHelper.AreEqual(() => m.Division.HasValue, false);
                }
            }

            TestCompetitors(dto.Competitors.ToList(), record.sport_event.competitors, _assertHelper);
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionDTO"/> class
        /// </summary>
        /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param>
        internal CompetitionDTO(matchSummaryEndpoint matchSummary)
            : this(matchSummary.sport_event)
        {
            Contract.Requires(matchSummary != null);

            Conditions = matchSummary.sport_event_conditions == null
                ? Conditions
                : new SportEventConditionsDTO(matchSummary.sport_event_conditions);

            Status = matchSummary.sport_event_status == null
                ? null
                : new SportEventStatusDTO(matchSummary.sport_event_status, matchSummary.statistics, HomeAwayCompetitors);

            Venue = matchSummary.sport_event_conditions?.venue == null
                ? Venue
                : new VenueDTO(matchSummary.sport_event_conditions.venue);

            if (Venue == null && matchSummary.venue != null)
            {
                Venue = new VenueDTO(matchSummary.venue);
            }
        }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchDTO"/> class
        /// </summary>
        /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param>
        internal MatchDTO(matchSummaryEndpoint matchSummary)
            : base(matchSummary)
        {
            Guard.Argument(matchSummary, nameof(matchSummary)).NotNull();

            if (matchSummary.sport_event.season != null)
            {
                Guard.Argument(matchSummary.sport_event.season.id, nameof(matchSummary.sport_event.season.id)).NotNull().NotEmpty();
                Guard.Argument(matchSummary.sport_event.season.name, nameof(matchSummary.sport_event.season.name)).NotNull().NotEmpty();
                Season = new SportEntityDTO(matchSummary.sport_event.season.id, matchSummary.sport_event.season.name);
            }
            if (matchSummary.sport_event.tournament_round != null)
            {
                Round = new RoundDTO(matchSummary.sport_event.tournament_round);
            }
            if (matchSummary.sport_event.tournament != null)
            {
                Guard.Argument(matchSummary.sport_event.tournament.id, nameof(matchSummary.sport_event.tournament.id)).NotNull().NotEmpty();
                Guard.Argument(matchSummary.sport_event.tournament.name, nameof(matchSummary.sport_event.tournament.name)).NotNull().NotEmpty();
                Tournament = new TournamentDTO(matchSummary.sport_event.tournament);
            }
        }
예제 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchDTO"/> class
        /// </summary>
        /// <param name="matchSummary">A <see cref="matchSummaryEndpoint"/> instance containing basic information about the sport event</param>
        internal MatchDTO(matchSummaryEndpoint matchSummary)
            : base(matchSummary)
        {
            Contract.Requires(matchSummary != null);

            if (matchSummary.sport_event.season != null)
            {
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.season.id));
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.season.name));
                Season = new SportEntityDTO(matchSummary.sport_event.season.id, matchSummary.sport_event.season.name);
            }
            if (matchSummary.sport_event.tournament_round != null)
            {
                Round = new RoundDTO(matchSummary.sport_event.tournament_round);
            }
            if (matchSummary.sport_event.tournament != null)
            {
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.tournament.id));
                Contract.Assume(!string.IsNullOrEmpty(matchSummary.sport_event.tournament.name));
                Tournament = new TournamentDTO(matchSummary.sport_event.tournament);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventSummaryMapper"/> class.
        /// </summary>
        /// <param name="matchSummaryData">A <see cref="matchSummaryEndpoint"/> containing match data</param>
        internal SportEventSummaryMapper(matchSummaryEndpoint matchSummaryData)
        {
            Guard.Argument(matchSummaryData, nameof(matchSummaryData)).NotNull();

            _matchSummaryData = matchSummaryData;
        }
예제 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventSummaryMapper"/> class.
        /// </summary>
        /// <param name="matchSummaryData">A <see cref="matchSummaryEndpoint"/> containing match data</param>
        internal SportEventSummaryMapper(matchSummaryEndpoint matchSummaryData)
        {
            Contract.Requires(matchSummaryData != null);

            _matchSummaryData = matchSummaryData;
        }
예제 #14
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="MatchSummaryMapper" /> class.
        /// </summary>
        /// <param name="data">A <see cref="matchSummaryEndpoint" /> containing sport event data</param>
        internal MatchSummaryMapper(matchSummaryEndpoint data)
        {
            Contract.Requires(data != null);

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

            _data = data;
        }