コード例 #1
0
                public void Game_Win_Percentage_Should_Be_Minimum(SwissStatisticsProvider sut, IEnumerable<Round> rounds, Player A, Player B)
                {
                    var actual = sut
                        .GetGameWinPercentage(rounds, A);

                    Assert.Equal(SwissStatisticsProvider.MinimumMatchWinPercentage, actual);
                }
コード例 #2
0
                public void Opponent_Match_Win_Percentage_Should_Be_One(SwissStatisticsProvider sut, IEnumerable<Round> rounds, Player A, Player B)
                {
                    var actual = sut
                        .GetOpponentsMatchWinPercentage(rounds, A);

                    Assert.Equal(1.0m, actual);
                }
コード例 #3
0
ファイル: PlayerStanding.cs プロジェクト: Jaecen/Peregrine
 public PlayerStanding(Player player, int rank, decimal matchPoints, decimal opponentsMatchWinPercentage, decimal gameWinPercentage, decimal opponentsGameWinPercentage)
 {
     Player = player;
     Rank = rank;
     MatchPoints = matchPoints;
     OpponentsMatchWinPercentage = opponentsMatchWinPercentage;
     GameWinPercentage = gameWinPercentage;
     OpponentsGameWinPercentage = opponentsGameWinPercentage;
 }
コード例 #4
0
ファイル: Player.cs プロジェクト: Jaecen/Peregrine
        public bool Equals(Player other)
        {
            if(Object.ReferenceEquals(other, null))
                return false;

            if(Object.ReferenceEquals(this, other))
                return true;

            return Identifier == other.Identifier;
        }
コード例 #5
0
ファイル: GameResult.cs プロジェクト: Jaecen/Peregrine
 public GameResult(Player winner)
 {
     Winner = winner;
 }
コード例 #6
0
                public void Should_Be_Awarded_No_Match_Points(SwissStatisticsProvider sut, IEnumerable<Round> rounds, Player A, Player B)
                {
                    var actual = sut
                        .GetMatchPoints(rounds, A);

                    Assert.Equal(0.0m, actual);
                }
コード例 #7
0
 public static IEnumerable<GameResult> CreateGameResults(Player A, Player B, int winsForA, int lossesForA, int draws)
 {
     return Enumerable
         .Range(0, winsForA)
         .Select(i => A)
         .Concat(Enumerable
             .Range(0, lossesForA)
             .Select(i => B))
         .Concat(Enumerable
             .Range(0, draws)
             .Select(i => (Player)null))
         .Select(player => new GameResult(player));
 }
コード例 #8
0
 public static Match CreateMatch(int matchNumber, Player A, Player B, int winsForA, int lossesForA, int draws)
 {
     return new Match(
             matchNumber,
             new[] { A, B },
             CreateGameResults(A, B, winsForA, lossesForA, draws)
         );
 }
コード例 #9
0
                public void Game_Win_Percentage_Should_Be_One_Third(SwissStatisticsProvider sut, IEnumerable<Round> rounds, Player A, Player B)
                {
                    var actual = sut
                        .GetGameWinPercentage(rounds, A);

                    Assert.Equal(1.0m / 3.0m, actual);
                }
コード例 #10
0
        public void Customize(IFixture fixture)
        {
            var winner = new Player("A", null);
            var loser = new Player("B", null);

            fixture.Inject(MockDataBuilder.CreateRounds(
                    new[]
                    {
                        new[]
                        {
                            Tuple.Create(winner, loser, Wins, Losses, Draws),
                        }
                    }
                ));
        }
コード例 #11
0
                public void Opponent_Game_Win_Percentage_Should_Be_Four_Ninths(SwissStatisticsProvider sut, IEnumerable<Round> rounds, Player A, Player B)
                {
                    var actual = sut
                        .GetOpponentsGameWinPercentage(rounds, A);

                    // One win + one draw = 4GP out of 9 possible
                    Assert.Equal(4.0m / 9.0m, actual);
                }
コード例 #12
0
                    public void One_Player_Should_Get_A_Bye(SwissRankingEngine sut, Player A, Player B, Player C)
                    {
                        // Seed 7357 = Round 1 pairing order { B, C, A }
                        var context = new SwissTournamentContext(
                            7357,
                            TournamentState.TournamentCreated,
                            new[] { A, B, C },
                            null,
                            null);

                        var actual = sut.GetPairings(context);

                        Assert.Equal(actual.Count(), 2);

                        var firstPairing = actual.ElementAt(0);
                        Assert.Equal(2, firstPairing.Players.Count());
                        Assert.Contains(B, firstPairing.Players);
                        Assert.Contains(C, firstPairing.Players);

                        var byePairing = actual.ElementAt(1);
                        Assert.Equal(1, byePairing.Players.Count());
                        Assert.Contains(A, byePairing.Players);
                    }
コード例 #13
0
                    public void All_Players_Should_Be_Paired(SwissRankingEngine sut, Player A, Player B, Player C, Player D)
                    {
                        // Seed 7357 = Round 1 pairing order { B, C, A, D }
                        var context = new SwissTournamentContext(
                            7357,
                            TournamentState.TournamentCreated,
                            new[] { A, B, C, D },
                            null,
                            null);

                        var actual = sut.GetPairings(context);

                        Assert.Equal(actual.Count(), 2);

                        var firstPairing = actual.ElementAt(0);
                        Assert.Equal(2, firstPairing.Players.Count());
                        Assert.Contains(B, firstPairing.Players);
                        Assert.Contains(C, firstPairing.Players);

                        var secondPairing = actual.ElementAt(1);
                        Assert.Equal(2, secondPairing.Players.Count());
                        Assert.Contains(A, secondPairing.Players);
                        Assert.Contains(D, secondPairing.Players);
                    }
コード例 #14
0
                public void Opponent_Game_Win_Percentage_Should_Be_Two_Thirds(SwissStatisticsProvider sut, IEnumerable<Round> rounds, Player A, Player B)
                {
                    var actual = sut
                        .GetOpponentsGameWinPercentage(rounds, A);

                    Assert.Equal(2.0m / 3.0m, actual);
                }
コード例 #15
0
ファイル: MatchResult.cs プロジェクト: Jaecen/Peregrine
 public MatchResult(int roundNumber, int matchNumber, Player winner)
 {
     RoundNumber = roundNumber;
     MatchNumber = matchNumber;
     Winner = winner;
 }