public void RoundMergeTest() { var matchRoundTypeEn = new matchRound { name = "round name in english", cup_round_match_number = 1, cup_round_match_numberSpecified = true, cup_round_matches = 2, cup_round_matchesSpecified = true, number = 10, numberSpecified = true, type = "match type 1", }; var matchRoundTypeDe = new matchRound { name = "round name in deutsch", cup_round_match_number = 1, cup_round_match_numberSpecified = true, cup_round_matches = 2, cup_round_matchesSpecified = true, number = 10, numberSpecified = true, type = "match type 1", }; var roundDTO1 = new RoundDTO(matchRoundTypeEn); var roundDTO2 = new RoundDTO(matchRoundTypeDe); var roundCI = new RoundCI(roundDTO1, _cultureFirst); roundCI.Merge(roundDTO2, _cultureSecond); Assert.IsNotNull(roundCI); Assert.AreEqual(matchRoundTypeEn.name, roundCI.GetName(_cultureFirst)); Assert.AreEqual(matchRoundTypeDe.name, roundCI.GetName(_cultureSecond)); Assert.AreEqual(matchRoundTypeEn.cup_round_match_number, roundCI.CupRoundMatchNumber); Assert.AreEqual(matchRoundTypeEn.cup_round_matches, roundCI.CupRoundMatches); Assert.AreEqual(matchRoundTypeEn.number, roundCI.Number); Assert.AreEqual(matchRoundTypeEn.type, roundCI.Type); }
private static void ValidateSportEventCacheItem(IMatchCI item, bool ignoreDate = false) { Assert.IsNotNull(item, "Cached item not found."); Assert.AreEqual(TestData.EventId, item.Id); var date = new DateTime?(); List <URN> competitors = null; TeamCompetitorCI comp = null; RoundCI round = null; SeasonCI season = null; Task.Run(async() => { date = await item.GetScheduledAsync(); competitors = (await item.GetCompetitorsIdsAsync(TestData.Cultures)).ToList(); //comp = competitors.FirstOrDefault(); round = await item.GetTournamentRoundAsync(TestData.Cultures); season = await item.GetSeasonAsync(TestData.Cultures); }).GetAwaiter().GetResult(); if (!ignoreDate) { if (date != null) { Assert.AreEqual(new DateTime(2016, 08, 10), new DateTime(date.Value.Year, date.Value.Month, date.Value.Day)); } } Assert.AreEqual(2, competitors.Count); //TODO - this was removed if (comp != null) { Assert.AreEqual("sr:competitor:66390", comp.Id.ToString()); Assert.AreEqual(@"Pericos de Puebla", comp.GetName(TestData.Culture)); Assert.AreEqual("Mexico", comp.GetCountry(TestData.Culture)); Assert.AreNotEqual(comp.GetCountry(TestData.Culture), comp.GetCountry(new CultureInfo("de"))); } Assert.IsTrue(string.IsNullOrEmpty(round.GetName(TestData.Culture))); Assert.AreEqual(3, season.Names.Count); Assert.AreEqual("Mexican League 2016", season.Names[TestData.Culture]); }
/// <summary> /// Initializes a new instance of the <see cref="Round"/> class /// </summary> /// <param name="ci">A <see cref="RoundCI"/> used to create new instance</param> /// <param name="cultures">A cultures of the current instance of <see cref="RoundCI"/></param> public Round(RoundCI ci, IEnumerable <CultureInfo> cultures) { Contract.Requires(ci != null); Type = ci.Type; Number = ci.Number; GroupName = ci.Group; GroupId = ci.GroupId; OtherMatchId = ci.OtherMatchId; CupRoundMatches = ci.CupRoundMatches; CupRoundMatchNumber = ci.CupRoundMatchNumber; Name = new Dictionary <CultureInfo, string>(); PhaseOrGroupLongName = new Dictionary <CultureInfo, string>(); foreach (var c in cultures) { Name.Add(c, ci.GetName(c)); PhaseOrGroupLongName.Add(c, ci.GetPhaseOrGroupLongName(c)); } BetradarId = ci.BetradarId ?? 0; Phase = ci.Phase; }
/// <summary> /// Initializes a new instance of the <see cref="Round"/> class /// </summary> /// <param name="ci">A <see cref="RoundCI"/> used to create new instance</param> /// <param name="cultures">A cultures of the current instance of <see cref="RoundCI"/></param> public Round(RoundCI ci, IEnumerable <CultureInfo> cultures) { Guard.Argument(ci, nameof(ci)).NotNull(); Type = ci.Type; Number = ci.Number; GroupName = ci.Group; GroupId = ci.GroupId; OtherMatchId = ci.OtherMatchId; CupRoundMatches = ci.CupRoundMatches; CupRoundMatchNumber = ci.CupRoundMatchNumber; Name = new Dictionary <CultureInfo, string>(); PhaseOrGroupLongName = new Dictionary <CultureInfo, string>(); foreach (var c in cultures) { Name.Add(c, ci.GetName(c)); PhaseOrGroupLongName.Add(c, ci.GetPhaseOrGroupLongName(c)); } BetradarId = ci.BetradarId ?? 0; Phase = ci.Phase; }
public static void ValidateTestEventId(MatchCI ci, IEnumerable <CultureInfo> cultures, bool canHaveOtherLanguage) { Assert.IsNotNull(ci, "Cached item not found."); Assert.AreEqual(EventId, ci.Id); if (cultures == null) { Assert.IsNull(ci); } var date = new DateTime?(); RoundCI round = null; SeasonCI season = null; var cultureInfos = cultures.ToList(); var cStr = string.Join(",", cultureInfos); var lStr = string.Join(",", ci.LoadedSummaries); Assert.IsTrue(ci.HasTranslationsFor(cultureInfos), $"Culture missing: {cStr}, loaded summaries: {lStr}"); if (!canHaveOtherLanguage) { Assert.IsTrue(ci.LoadedSummaries.Count >= cultureInfos.Count || ci.LoadedFixtures.Count >= cultureInfos.Count); } foreach (var culture in cultureInfos) { var checkCulture = new[] { culture }; Task.Run(async() => { date = await ci.GetScheduledAsync(); round = await ci.GetTournamentRoundAsync(checkCulture); season = await ci.GetSeasonAsync(checkCulture); }).GetAwaiter().GetResult(); Debug.Assert(date != null, "date != null"); Assert.AreEqual(new DateTime(2016, 08, 10), new DateTime(date.Value.Year, date.Value.Month, date.Value.Day)); Assert.IsTrue(string.IsNullOrEmpty(round.GetName(culture))); Assert.IsTrue(Math.Max(ci.LoadedSummaries.Count, ci.LoadedFixtures.Count) >= season.Names.Count); } }
internal static void ValidateTestEventId(MatchCI ci, IEnumerable <CultureInfo> cultures, bool canHaveOtherLanguage) { Assert.IsNotNull(ci, "Cached item not found."); Assert.AreEqual(EventId, ci.Id); if (cultures == null) { Assert.IsNull(ci); } var date = new DateTime?(); List <TeamCompetitorCI> competitors = null; TeamCompetitorCI comp = null; RoundCI round = null; CacheItem season = null; var cultureInfos = cultures.ToList(); var cStr = string.Join(",", cultureInfos); var lStr = string.Join(",", ci.LoadedSummaries); Assert.IsTrue(ci.HasTranslationsFor(cultureInfos), $"Culture missing: {cStr}, loaded summaries: {lStr}"); if (!canHaveOtherLanguage) { Assert.IsTrue(ci.LoadedSummaries.Count >= cultureInfos.Count || ci.LoadedFixtures.Count >= cultureInfos.Count); } foreach (var culture in cultureInfos) { var checkCulture = new[] { culture }; Task.Run(async() => { date = await ci.GetScheduledAsync(); //competitors = (await ci.GetCompetitorsAsync(checkCulture)).ToList(); // ReSharper disable once AssignNullToNotNullAttribute //comp = competitors.FirstOrDefault(); round = await ci.GetTournamentRoundAsync(checkCulture); season = await ci.GetSeasonAsync(checkCulture); }).GetAwaiter().GetResult(); Debug.Assert(date != null, "date != null"); Assert.AreEqual(new DateTime(2016, 08, 10), new DateTime(date.Value.Year, date.Value.Month, date.Value.Day)); //Assert.AreEqual(2, competitors.Count); //TODO - this was removed if (comp != null) { Assert.AreEqual("sr:competitor:66390", comp.Id.ToString()); Assert.AreEqual(@"Pericos de Puebla", comp.GetName(culture)); if (Equals(culture, Culture)) { Assert.AreEqual("Mexico", comp.GetCountry(culture)); Assert.AreEqual("Mexican League 2016", season.Name[culture]); } if (culture.TwoLetterISOLanguageName != "de") { Assert.AreNotEqual(comp.GetCountry(culture), comp.GetCountry(new CultureInfo("de"))); } } Assert.IsTrue(string.IsNullOrEmpty(round.GetName(culture))); Assert.IsTrue(Math.Max(ci.LoadedSummaries.Count, ci.LoadedFixtures.Count) >= season.Name.Count); } }