public void AddSamePlayerToSameTeamTwice_ThrowsInvalidOperationException() { var playerIdentifier = new EloPlayerIdentifier(); var player = new EloPlayer(playerIdentifier, 1350); var team = new EloTeam(player, true); Assert.Throws <InvalidOperationException>(() => team.AddPlayer(player)); }
public void AddPlayerWithSameIdentifierToTwoTeams_ThrowsArgumentException() { var playerIdentifier = new EloPlayerIdentifier(); var player1 = new EloPlayer(playerIdentifier, 1350); var player2 = new EloPlayer(playerIdentifier, 1330); Assert.Throws <ArgumentException>(() => new EloMatch(new[] { new EloTeam(player1, true), new EloTeam(player2, false) })); }
public void CreateMatchDynamically_AddSamePlayer_ThrowsArgumentException() { var match = new EloMatch(); var teamIdentifier = match.AddTeam(new EloTeam(true)); var player = new EloPlayer(1200); match.AddPlayerToTeam(teamIdentifier, player); Assert.Throws <ArgumentException>(() => match.AddPlayerToTeam(teamIdentifier, player)); }
public void PlayerWithSameIdentifierAndRating_AssertEquality() { var identifier = new EloPlayerIdentifier(Guid.NewGuid()); var rating = new EloRating(1200); var player1 = new EloPlayer(identifier, rating); var player2 = new EloPlayer(identifier, rating); Assert.AreEqual(player1, player2); Assert.IsTrue(player1 == player2); Assert.IsTrue(player1.Equals(player2)); }
public void SimpleMatch_Player1Wins() { var player1 = new EloPlayer(1200); var player2 = new EloPlayer(1300); var teams = new List <EloTeam> { new EloTeam(player1, true), new EloTeam(player2, false) }; var match = new EloMatch(teams); var result = match.Calculate(); var player1EloDiff = result.GetRatingDifference(player1.Identifier); var player2EloDiff = result.GetRatingDifference(player2.Identifier); Assert.Greater(player1EloDiff, player2EloDiff); }
public void TwoTeamsWithSamePlayers_AssertEquality() { var playerIdentifier = new EloPlayerIdentifier(); var rating = new EloRating(1200); var player1 = new EloPlayer(playerIdentifier, rating); var player2 = new EloPlayer(playerIdentifier, rating); var teamIdentifier = new EloTeamIdentifier(); var team1 = new EloTeam(teamIdentifier, player1, true); var team2 = new EloTeam(teamIdentifier, player2, false); Assert.AreEqual(team1, team2); Assert.IsTrue(team1 == team2); Assert.IsTrue(team1.Equals(team2)); }
public IEloPlayer AddPlayer(int rank, float elo) { var player = new EloPlayer { Id = this._players.Count, Rank = rank, OldElo = elo, NewElo = elo, EloChange = 0 }; this._players.Add(player.Id, player); return(player); }
public void SimpleMatch_SetKFactorAs0_Player1Wins_NoEloGained() { var player1 = new EloPlayer(1200); var player2 = new EloPlayer(1300); var players = new List <EloTeam> { new EloTeam(player1, true), new EloTeam(player2, false) }; var match = new EloMatch(players); match.SetKFactor(0); var result = match.Calculate(); var player1EloDiff = result.GetRatingDifference(player1.Identifier); var player2EloDiff = result.GetRatingDifference(player2.Identifier); Assert.AreEqual(0, player1EloDiff); Assert.AreEqual(0, player2EloDiff); }
public void AddPlayerToTwoTeams_ThrowsArgumentException() { var player = new EloPlayer(1350); Assert.Throws <ArgumentException>(() => new EloMatch(new[] { new EloTeam(player, true), new EloTeam(player, false) })); }