Example #1
0
        public void VenueMergeTest()
        {
            var venue1 = new venue
            {
                id                = SR.Urn("venue").ToString(),
                capacity          = 5,
                capacitySpecified = true,
                city_name         = "my city",
                country_name      = "eng country name",
                state             = "state",
                map_coordinates   = "coordinates",
                name              = "eng name"
            };
            var venue2 = new venue
            {
                id                = SR.Urn("venue").ToString(),
                capacity          = 5,
                capacitySpecified = true,
                city_name         = "my city",
                country_name      = "de country name",
                state             = "state",
                map_coordinates   = "coordinates",
                name              = "eng name"
            };
            var venueDTO1 = new VenueDTO(venue1);
            var venueDTO2 = new VenueDTO(venue2);
            var venueCI   = new VenueCI(venueDTO1, _cultureFirst);

            venueCI.Merge(venueDTO2, _cultureSecond);

            Assert.IsNotNull(venueCI);
            Assert.AreEqual(venue1.id, venueCI.Id.ToString());
            Assert.AreEqual(venue1.name, venueCI.GetName(_cultureFirst));
            Assert.AreEqual(venue1.capacity, venueCI.Capacity);
            Assert.AreEqual(venue1.map_coordinates, venueCI.Coordinates);
            Assert.AreEqual(venue1.state, venueCI.State);
            Assert.AreEqual(venue1.city_name, venueCI.GetCity(_cultureFirst));
            Assert.AreEqual(venue1.country_name, venueCI.GetCountry(_cultureFirst));
            Assert.AreEqual(venue2.country_name, venueCI.GetCountry(_cultureSecond));
            Assert.AreNotEqual(venueCI.GetCountry(_cultureFirst), venueCI.GetCountry(_cultureSecond));
        }
        /// <summary>
        ///     Merges the specified event summary
        /// </summary>
        /// <param name="eventSummary">The event summary</param>
        /// <param name="culture">The culture</param>
        private void ActualMerge(CompetitionDTO eventSummary, CultureInfo culture)
        {
            base.Merge(eventSummary, culture, false);

            if (eventSummary.Venue != null)
            {
                if (_venue == null)
                {
                    _venue = new VenueCI(eventSummary.Venue, culture);
                }
                else
                {
                    _venue.Merge(eventSummary.Venue, culture);
                }
            }

            if (eventSummary.Conditions != null)
            {
                if (_conditions == null)
                {
                    _conditions = new SportEventConditionsCI(eventSummary.Conditions, culture);
                }
                else
                {
                    _conditions.Merge(eventSummary.Conditions, culture);
                }
            }

            if (eventSummary.Competitors != null)
            {
                Competitors = new List <URN>(eventSummary.Competitors.Select(t => t.Id));
                GenerateMatchName(eventSummary.Competitors, culture);
                FillCompetitorsQualifiers(eventSummary.Competitors);
                FillCompetitorsReferences(eventSummary.Competitors);
            }

            if (eventSummary.BookingStatus != null)
            {
                _bookingStatus = eventSummary.BookingStatus;
            }
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionCI" /> class
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableSportEventCI" /> representing the sport event</param>
        /// <param name="dataRouterManager">The <see cref="IDataRouterManager"/> used to obtain summary and fixture</param>
        /// <param name="semaphorePool">A <see cref="ISemaphorePool" /> instance used to obtain sync objects</param>
        /// <param name="defaultCulture">A <see cref="CultureInfo" /> specifying the language used when fetching info which is not translatable (e.g. Scheduled, ..)</param>
        /// <param name="fixtureTimestampCache">A <see cref="ObjectCache"/> used to cache the sport events fixture timestamps</param>
        public CompetitionCI(ExportableSportEventCI exportable,
                             IDataRouterManager dataRouterManager,
                             ISemaphorePool semaphorePool,
                             CultureInfo defaultCulture,
                             ObjectCache fixtureTimestampCache)
            : base(exportable, dataRouterManager, semaphorePool, defaultCulture, fixtureTimestampCache)
        {
            var exportableCompetition = exportable as ExportableCompetitionCI;

            if (exportableCompetition != null)
            {
                _bookingStatus = exportableCompetition.BookingStatus;
                _venue         = exportableCompetition.Venue != null ? new VenueCI(exportableCompetition.Venue) : null;
                _conditions    = exportableCompetition.Conditions != null
                    ? new SportEventConditionsCI(exportableCompetition.Conditions)
                    : null;
                Competitors = exportableCompetition.Competitors != null
                    ? new List <URN>(exportableCompetition.Competitors.Select(URN.Parse))
                    : null;
                _referenceId = exportableCompetition.ReferenceId != null
                    ? new ReferenceIdCI(exportableCompetition.ReferenceId)
                    : null;
                _competitorsQualifiers = exportableCompetition.CompetitorsQualifiers != null
                    ? new Dictionary <URN, string>(
                    exportableCompetition.CompetitorsQualifiers.ToDictionary(c => URN.Parse(c.Key), c => c.Value))
                    : null;
                _competitorsReferences = exportableCompetition.CompetitorsReferences != null
                    ? new Dictionary <URN, ReferenceIdCI>(
                    exportableCompetition.CompetitorsReferences.ToDictionary(c => URN.Parse(c.Key),
                                                                             c => new ReferenceIdCI(c.Value)))
                    : null;
                _competitorsVirtual = exportableCompetition.CompetitorsVirtual != null
                                          ? exportableCompetition.CompetitorsVirtual.Select(URN.Parse).ToList()
                                          : new List <URN>();

                _liveOdds       = string.IsNullOrEmpty(exportableCompetition.LiveOdds) ? null : exportableCompetition.LiveOdds;
                _sportEventType = exportableCompetition.SportEventType;
                _stageType      = exportableCompetition.StageType;
            }
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Venue"/> class.
        /// </summary>
        /// <param name="ci">A <see cref="VenueCI"/> used to create new instance</param>
        /// <param name="cultures">A culture of the current instance of <see cref="VenueCI"/></param>
        public Venue(VenueCI ci, IEnumerable <CultureInfo> cultures)
        {
            Guard.Argument(ci, nameof(ci)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull();//.NotEmpty();
            if (!cultures.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(cultures));
            }

            var cultureList = cultures as IList <CultureInfo> ?? cultures.ToList();

            Id          = ci.Id;
            Coordinates = ci.Coordinates;
            Capacity    = ci.Capacity;

            Names       = new ReadOnlyDictionary <CultureInfo, string>(cultureList.Where(c => ci.GetName(c) != null).ToDictionary(c => c, ci.GetName));
            Cities      = new ReadOnlyDictionary <CultureInfo, string>(cultureList.Where(c => ci.GetCity(c) != null).ToDictionary(c => c, ci.GetCity));
            Countries   = new ReadOnlyDictionary <CultureInfo, string>(cultureList.Where(c => ci.GetCountry(c) != null).ToDictionary(c => c, ci.GetCountry));
            CountryCode = ci.CountryCode;
            State       = ci.State;
            Course      = ci.Course?.Select(s => new Hole(s));
        }