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);
                }
                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);
                }
Example #3
0
 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;
 }
Example #4
0
        public bool Equals(Player other)
        {
            if(Object.ReferenceEquals(other, null))
                return false;

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

            return Identifier == other.Identifier;
        }
Example #5
0
 public GameResult(Player winner)
 {
     Winner = winner;
 }
                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);
                }
 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));
 }
 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)
         );
 }
                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);
                }
        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),
                        }
                    }
                ));
        }
                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);
                }
                    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);
                    }
                    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);
                    }
                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);
                }
Example #15
0
 public MatchResult(int roundNumber, int matchNumber, Player winner)
 {
     RoundNumber = roundNumber;
     MatchNumber = matchNumber;
     Winner = winner;
 }