public void KnockoutStage_Play_Nominal() { var teams = JsonConvert.DeserializeObject <List <Team> >(TestTools.GetFileContent("teams")); var kos = new KnockoutStage(teams, false, true); Assert.IsTrue(teams.Skip(9).ToList().All(t => kos.NextMatchDayToPlay.Matches.SelectMany(m => m.Teams).Contains(t))); kos.Play(); kos.Play(); Assert.AreEqual(16, kos.NextMatchDayToPlay.Matches.Count); Assert.IsTrue(teams.Take(9).ToList().All(t => kos.NextMatchDayToPlay.Matches.SelectMany(m => m.Teams).Contains(t))); kos.Play(); kos.Play(); Assert.AreEqual(8, kos.NextMatchDayToPlay.Matches.Count); kos.Play(); kos.Play(); Assert.AreEqual(4, kos.NextMatchDayToPlay.Matches.Count); kos.Play(); kos.Play(); Assert.AreEqual(2, kos.NextMatchDayToPlay.Matches.Count); kos.Play(); kos.Play(); Assert.AreEqual(1, kos.NextMatchDayToPlay.Matches.Count); kos.Play(); Assert.IsNull(kos.NextMatchDayToPlay); }
public void KnockoutStage_Ctor_Nominal(bool oneLeg) { var teams = JsonConvert.DeserializeObject <List <Team> >(TestTools.GetFileContent("teams")); var kos = new KnockoutStage(teams, oneLeg, oneLeg); var matchDays = kos.NextMatchDayToPlay; Assert.AreEqual(23, matchDays.Matches.Count); var actualTeams = matchDays.Matches.SelectMany(m => m.Teams); Assert.IsTrue(actualTeams.All(t => teams.Skip(9).ToList().Contains(t))); Assert.AreEqual(oneLeg ? 1 : 2, kos.MatchDays.Count); }
public KnockoutStageSeason Build() { var stage = new KnockoutStage(pairCount); var season = new KnockoutStageSeason(stage); season.CupSeason = A.CupSeason.Build(); if (isScheduled) { season.ScheduleRoundDates(new DateTime[] { A.Date }); } if (isActivated) { season.Activate(A.Team.Repeat(pairCount * 2)); } return season; }