コード例 #1
0
        public void ModifyingPlayerList_ResetsRounds()
        {
            var tournament = new Tournament(new PairingGenerator(), 1) { Players = new[] { P1, P2 } };
            var round = tournament.Rounds.First();
            round.Pairings = tournament.RandomizePairings();
            Assert.NotNull(tournament.Rounds.First().Pairings);

            tournament.Players = new[] { P1, P2, P3 };
            Assert.NotEqual(round, tournament.Rounds.First());
            Assert.Empty(tournament.Rounds.First().Pairings);
        }
コード例 #2
0
        public void GetStandings_ReturnsPlayersWithScoresInDescOrder()
        {
            var tournament = new Tournament(new PairingGenerator(), 2) { Players = new[] { P1, P2, P3, P4 } };
            var pairings = tournament.RandomizePairings().ToList();
            pairings[0].SetScore(15, 5);
            pairings[1].SetScore(10, 10);

            PairingGenerator.Setup(
                pg => pg.Swiss(It.IsAny<IOrderedEnumerable<KeyValuePair<Player, int>>>(), It.IsAny<IList<Pairing>>()))
                .Returns(pairings);
            var standings = new Round { Pairings = pairings }.GetStandings().Select(i => i.Value).ToList();

            Assert.Equal(tournament.Players.Count(), standings.Count);
            Assert.Equal(standings, standings.OrderByDescending(i => i));
        }