Exemplo n.º 1
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");
        }
Exemplo n.º 2
0
        public void CompetitorProfileDTOMappingTest()
        {
            var msg = RMF.GetCompetitorProfileEndpoint(0, 10);

            var dto = new CompetitorProfileDTO(msg);

            ValidateTeamExtended(msg.competitor, dto.Competitor); //TODO: missing extended properties
            Assert.AreEqual(msg.players.Length, dto.Players.Count());

            for (var i = 0; i < msg.players.Length; i++)
            {
                ValidatePlayerExtended(msg.players[i], dto.Players.ToArray()[i]);
            }
        }