예제 #1
0
 private static void ValidateTeamCompetitor(teamCompetitor msg, TeamCompetitorCI ci, CultureInfo culture)
 {
     Assert.AreEqual(msg.id, ci.Id.ToString());
     Assert.AreEqual(msg.name, ci.GetName(culture));
     Assert.AreEqual(msg.abbreviation, ci.GetAbbreviation(culture));
     Assert.AreEqual(msg.country, ci.GetCountry(culture));
     Assert.AreEqual(msg.@virtual, ci.IsVirtual);
     Assert.AreEqual(msg.qualifier, ci.Qualifier);
     Assert.AreEqual(msg.divisionSpecified, ci.Division.HasValue);
     Assert.AreEqual(msg.division, ci.Division);
 }
예제 #2
0
        public void TeamCompetitorMergeTest()
        {
            var teamType1 = new teamCompetitor
            {
                abbreviation      = "ABC",
                country           = "Germany",
                id                = "sr:team:1",
                name              = "Team A",
                @virtual          = true,
                virtualSpecified  = true,
                qualifier         = "qua 1",
                divisionSpecified = true,
                division          = 1,
                state             = "state"
            };
            var teamType2 = new teamCompetitor
            {
                abbreviation      = "ABC",
                country           = "Deutschland",
                id                = "sr:team:1",
                name              = "Team A",
                @virtual          = true,
                virtualSpecified  = true,
                qualifier         = "qua 1",
                divisionSpecified = true,
                division          = 1,
                state             = "state"
            };
            var competitorDTO1 = new TeamCompetitorDTO(teamType1);
            var competitorDTO2 = new TeamCompetitorDTO(teamType2);

            var competitorCI = new TeamCompetitorCI(competitorDTO1, _cultureFirst, new TestDataRouterManager(new CacheManager()));

            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(competitorCI.Qualifier, teamType1.qualifier);
            Assert.AreEqual(competitorCI.State, teamType1.state);
            Assert.AreEqual(teamType1.country, competitorCI.GetCountry(_cultureFirst));
            Assert.AreEqual(teamType2.country, competitorCI.GetCountry(_cultureSecond));
            Assert.IsNotNull(competitorCI.Division);
            Assert.AreEqual(competitorCI.Division.Value, teamType1.division);
        }
예제 #3
0
        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]);
        }
예제 #4
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);
            }
        }