Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
            }
        }