Пример #1
0
        public void CompetitorTest()
        {
            var teamType1 = new team
            {
                abbreviation     = "ABC",
                country          = "Germany",
                id               = SR.Urn("team").ToString(),
                name             = "Team A",
                @virtual         = true,
                virtualSpecified = true
            };
            var teamType2 = new team
            {
                abbreviation     = "ABC",
                country          = "Deutschland",
                id               = SR.Urn("team").ToString(),
                name             = "Team A",
                @virtual         = true,
                virtualSpecified = true
            };
            var competitorDTO1 = new CompetitorDTO(teamType1);
            var competitorDTO2 = new CompetitorDTO(teamType2);

            var competitorCI = new CompetitorCI(competitorDTO1, _cultureFirst, null);

            competitorCI.Merge(competitorDTO2, _cultureSecond);

            Assert.IsNotNull(competitorCI);
            Assert.AreEqual(competitorCI.Id.ToString(), teamType1.id);
            Assert.AreEqual(competitorCI.GetName(_cultureFirst), teamType1.name);
            Assert.AreEqual(competitorCI.GetAbbreviation(_cultureFirst), teamType1.abbreviation);
            Assert.AreEqual(competitorCI.IsVirtual, teamType1.@virtual);
            Assert.AreEqual(teamType1.country, competitorCI.GetCountry(_cultureFirst));
            Assert.AreEqual(teamType2.country, competitorCI.GetCountry(_cultureSecond));
        }
Пример #2
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));
        }
Пример #3
0
        public void SeasonCoverageMergeTest()
        {
            var coverageInfoCI = new SeasonCoverageCI(new SeasonCoverageDTO(RestMessageBuilder.BuildCoverageRecord("max", "min", 4, 1, 1, SR.Urn("season").ToString())));

            Assert.IsNotNull(coverageInfoCI);
            Assert.AreEqual("max", coverageInfoCI.MaxCoverageLevel);
            Assert.AreEqual("min", coverageInfoCI.MinCoverageLevel);
            Assert.AreEqual(4, coverageInfoCI.MaxCovered);
            Assert.AreEqual(1, coverageInfoCI.Played);
        }
Пример #4
0
        private async Task GetCompetitorProfileAsync(URN id, CultureInfo culture, ISportEventCI requester)
        {
            Debug.Print($"DRM-GetCompetitorProfileAsync for {id} and culture {culture.TwoLetterISOLanguageName} - START");
            var filePath             = GetFile($"{culture.TwoLetterISOLanguageName}.competitor.{id?.Id ?? 1}.xml", culture);
            CompetitorProfileDTO dto = null;

            await ExecuteDelayAsync(id, culture).ConfigureAwait(false);

            if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
            {
                //filePath = GetFile(CompetitorProfileXml, culture);
                dto = new CompetitorProfileDTO(MessageFactoryRest.GetCompetitorProfileEndpoint(id == null ? 1 : (int)id.Id, StaticRandom.I(15)));
            }
            else
            {
                var restDeserializer = new Deserializer <competitorProfileEndpoint>();
                var mapper           = new CompetitorProfileMapperFactory();
                var stream           = FileHelper.OpenFile(filePath);
                dto = mapper.CreateMapper(restDeserializer.Deserialize(stream)).Map();
            }

            if (dto != null)
            {
                await LogSaveDtoAsync(id, dto, culture, DtoType.CompetitorProfile, requester).ConfigureAwait(false);
            }
            Debug.Print($"DRM-GetCompetitorProfileAsync for {id} and culture {culture.TwoLetterISOLanguageName} - END");
        }