public void ShouldCreateClientWithDefaultRegion() { RiotClient.DefaultRegion = Region.EUNE; IRiotClient client = new RiotClient(); Assert.That(client.Region, Is.EqualTo(Region.EUNE)); }
public async Task GetGamesBySummonerIdAsyncTests() { IRiotClient client = new RiotClient(); var summonerId = 35870943; var games = await client.GetGamesBySummonerIdAsync(summonerId); Assert.That(games, Is.Not.Null); Assert.That(games.Games, Is.Not.Null.And.Not.Empty); Assert.That(games.SummonerId, Is.EqualTo(summonerId)); var game = games.Games.First(); Assert.That(game, Is.Not.Null); Assert.That(game.ChampionId, Is.GreaterThan(0)); Assert.That(game.CreateDate.Kind, Is.EqualTo(DateTimeKind.Utc)); Assert.That(game.CreateDate, Is.GreaterThan(default(DateTime)).And.LessThan(DateTime.UtcNow)); var fellowPlayers = games.Games.Where(g => g.FellowPlayers != null).SelectMany(g => g.FellowPlayers).ToList(); Assert.That(fellowPlayers, Is.Not.Empty); var player = fellowPlayers.First(); Assert.That(player.ChampionId, Is.GreaterThan(0)); Assert.That(player.SummonerId, Is.GreaterThan(0)); Assert.That(fellowPlayers.Any(p => p.TeamId == TeamSide.Team1)); Assert.That(fellowPlayers.Any(p => p.TeamId == TeamSide.Team2)); Assert.That(game.GameId, Is.GreaterThan(0)); Assert.That(game.Level, Is.GreaterThan(0)); Assert.That(game.MapId, Is.GreaterThan(0)); Assert.That(game.Spell1, Is.GreaterThan(0)); Assert.That(game.Spell2, Is.GreaterThan(0)); Assert.That(game.Stats, Is.Not.Null); Assert.That(game.Stats, Is.Not.Null); Assert.That(games.Games.Any(g => g.TeamId == TeamSide.Team1)); Assert.That(games.Games.Any(g => g.TeamId == TeamSide.Team2)); }
public async Task CreateTournamentAsyncTest() { IRiotClient client = new RiotClient(Region.NA, TournamentApiKey); var tournamentId = await client.CreateTournamentAsync(206, "test"); Assert.That(tournamentId, Is.GreaterThan(0)); }
public async Task GetMatchIdsByTournamentCodeAsyncTest() { IRiotClient client = new RiotClient(Region.NA, TournamentApiKey); var matchIds = await client.GetMatchIdsByTournamentCodeAsync("NA0418d-8899c00a-45a9-4898-9b8a-75370a67b9a0"); Assert.That(matchIds, Is.Not.Null.And.Not.Empty); }
public void RateLimitTest_ShouldThrow() { IRiotClient client = new RiotClient(); client.Settings.RetryOnRateLimitExceeded = false; client.Settings.ThrowOnError = true; Assert.ThrowsAsync<RateLimitExceededException>(() => MaxOutRateLimit(client)); }
public async Task UpdateTournamentCodeAsyncTest() { const string code = "NA042f7-b6923650-58bd-4a39-a5f5-9bd398016913"; IRiotClient client = new RiotClient(Region.NA, TournamentApiKey); await client.UpdateTournamentCodeAsync(code, new List<long> { 35870943L, 32153637L, 31220286L, 37431081L, 20934656L, 30545906L, 32550537L, 38722060L, 21204597L, 20028460L }, MapType.SUMMONERS_RIFT, PickType.BLIND_PICK, SpectatorType.ALL); var tournamentCode = await client.GetTournamentCodeAsync(code); Assert.That(tournamentCode.Map, Is.EqualTo(MapType.SUMMONERS_RIFT)); Assert.That(tournamentCode.Participants, Contains.Item(35870943L)); Assert.That(tournamentCode.PickType, Is.EqualTo(PickType.BLIND_PICK)); Assert.That(tournamentCode.Spectators, Is.EqualTo(SpectatorType.ALL)); await client.UpdateTournamentCodeAsync(code, new List<long> { 22811529L, 32153637L, 31220286L, 37431081L, 20934656L, 30545906L, 32550537L, 38722060L, 21204597L, 20028460L }, MapType.HOWLING_ABYSS, PickType.ALL_RANDOM, SpectatorType.LOBBYONLY); tournamentCode = await client.GetTournamentCodeAsync(code); Assert.That(tournamentCode.Map, Is.EqualTo(MapType.HOWLING_ABYSS)); Assert.That(tournamentCode.Participants, Contains.Item(22811529L)); Assert.That(tournamentCode.PickType, Is.EqualTo(PickType.ALL_RANDOM)); Assert.That(tournamentCode.Spectators, Is.EqualTo(SpectatorType.LOBBYONLY)); }
public async Task GetChampionMasteryScoreAsyncTest() { IRiotClient client = new RiotClient(); var score = await client.GetChampionMasteryScoreAsync(34172230L); Assert.That(score, Is.AtLeast(1)); }
public async Task CreateTournamentProviderAsyncTest() { IRiotClient client = new RiotClient(Region.NA, TournamentApiKey); var tournamentProviderId = await client.CreateTournamentProviderAsync("http://example.com"); Assert.That(tournamentProviderId, Is.GreaterThan(0)); }
public async Task GetChampionsAsyncTest() { IRiotClient client = new RiotClient(); var champions = await client.GetChampionsAsync(); Assert.That(champions, Is.Not.Null); Assert.That(champions.Count, Is.GreaterThan(100)); }
public async Task GetChampionsAsyncTest_FreeToPlay() { IRiotClient client = new RiotClient(); var champions = await client.GetChampionsAsync(true); Assert.That(champions, Is.Not.Null); Assert.That(champions.Count, Is.LessThan(25)); }
public async Task GetChampionByIdAsyncTest() { IRiotClient client = new RiotClient(); var champion = await client.GetChampionByIdAsync(103); Assert.That(champion, Is.Not.Null); Assert.That(champion.Id, Is.EqualTo(103)); }
public async Task CreateTournamentCodeAsyncTest() { IRiotClient client = new RiotClient(Region.NA, TournamentApiKey); var codes = await client.CreateTournamentCodeAsync(3092); Assert.That(codes, Is.Not.Null.And.Not.Empty); Assert.That(codes.Count, Is.EqualTo(1)); }
public async Task GetTeamsBySummonerIdsAsyncTest() { IRiotClient client = new RiotClient(Region.NA); var teams = await client.GetTeamsBySummonerIdsAsync(35870943, 34317083); Assert.That(teams, Is.Not.Null); Assert.That(teams.Keys.Count, Is.GreaterThan(0)); Assert.That(teams.Count, Is.GreaterThan(0)); var summonerTeams = teams["35870943"]; Assert.That(summonerTeams, Is.Not.Null.And.Not.Empty); var team = summonerTeams[0]; Assert.That(team.CreateDate, Is.GreaterThan(default(DateTime))); Assert.That(team.FullId, Is.Not.Null.And.Not.Empty); Assert.That(team.LastGameDate, Is.GreaterThan(default(DateTime))); Assert.That(team.LastJoinDate, Is.GreaterThan(default(DateTime))); Assert.That(team.LastJoinedRankedTeamQueueDate, Is.GreaterThan(default(DateTime))); Assert.That(team.MatchHistory, Is.Not.Null.And.Not.Empty); Assert.That(team.ModifyDate, Is.GreaterThan(default(DateTime))); Assert.That(team.Name, Is.Not.Null.And.Not.Empty); Assert.That(team.Roster, Is.Not.Null); Assert.That(team.SecondLastJoinDate, Is.GreaterThan(default(DateTime))); Assert.That(team.Status, Is.Not.Null.And.Not.Empty); Assert.That(team.Tag, Is.Not.Null.And.Not.Empty); Assert.That(team.TeamStatDetails, Is.Not.Null.And.Not.Empty); Assert.That(team.ThirdLastJoinDate, Is.GreaterThan(default(DateTime))); var matchHistory = team.MatchHistory[0]; Assert.That(team.MatchHistory.Any((x) => x.Assists > 0)); Assert.That(matchHistory.Date, Is.GreaterThan(default(DateTime))); Assert.That(team.MatchHistory.Any((x) => x.Deaths > 0)); Assert.That(matchHistory.GameId, Is.GreaterThan(0)); Assert.That(matchHistory.GameMode, Is.EqualTo(GameMode.CLASSIC)); // Loss prevented is pretty rare these days so Invalid is hard to test //Assert.That(summonerTeams.Any((x) => x.MatchHistory?.Any((y) => y.Invalid) == true)); Assert.That(team.MatchHistory.Any((x) => x.Kills > 0)); Assert.That(matchHistory.MapId, Is.GreaterThan(0)); Assert.That(team.MatchHistory.Any((x) => x.OpposingTeamKills > 0)); Assert.That(matchHistory.OpposingTeamName, Is.Not.Null.And.Not.Empty); Assert.That(team.MatchHistory.Any((x) => x.Win)); var roster = team.Roster; Assert.That(roster.MemberList, Is.Not.Null.And.Not.Empty); Assert.That(roster.OwnerId, Is.GreaterThan(0)); var teamMember = roster.MemberList[0]; Assert.That(teamMember.InviteDate, Is.GreaterThan(default(DateTime))); Assert.That(teamMember.JoinDate, Is.GreaterThan(default(DateTime))); Assert.That(teamMember.PlayerId, Is.GreaterThan(0)); Assert.That(teamMember.Status, Is.Not.Null.And.Not.Empty); var teamStatDetails = team.TeamStatDetails[0]; Assert.That(team.TeamStatDetails.Any((x) => x.Losses > 0)); Assert.That(teamStatDetails.AverageGamesPlayed, Is.EqualTo(0)); Assert.That(team.TeamStatDetails.Any((x) => x.Wins > 0)); Assert.That(team.TeamStatDetails.Any((x) => x.TeamStatType == RankedQueue.RANKED_TEAM_3x3)); }
public async Task GetShardsAsyncTest() { IRiotClient client = new RiotClient(); var shards = await client.GetShardsAsync(); Assert.That(shards, Is.Not.Null.And.Not.Empty); var shard = shards.First(); Assert.That(shard.Name, Is.Not.Null.And.Not.Empty); }
public async Task GetStatsSummaryAsyncTest() { IRiotClient client = new RiotClient(); var stats = await client.GetStatsSummaryAsync(35870943L); Assert.That(stats, Is.Not.Null); Assert.That(stats.PlayerStatSummaries, Is.Not.Null.And.Not.Empty); Assert.That(stats.SummonerId, Is.EqualTo(35870943L)); }
public void PlatformId_Property_ShouldBeCorrectForAllRegions() { foreach (Region region in Enum.GetValues(typeof(Region))) { IRiotClient client = new RiotClient(region); var expectedPlatformId = RiotClient.GetPlatformId(region); Assert.That(client.PlatformId, Is.EqualTo(expectedPlatformId)); } }
public async Task GetShardStatusAsyncTest() { IRiotClient client = new RiotClient(); var shard = await client.GetShardStatusAsync(); Assert.That(shard, Is.Not.Null); Assert.That(shard.Name, Is.Not.Null.And.Not.Empty); Assert.That(shard.Slug, Is.Not.Null.And.Not.Empty); }
public async Task GetMatchForTournamentAsyncTest() { IRiotClient client = new RiotClient(Region.NA, TournamentApiKey); const long matchId = 2035034934L; var match = await client.GetMatchForTournamentAsync(matchId, "NA0418d-8899c00a-45a9-4898-9b8a-75370a67b9a0"); Assert.That(match, Is.Not.Null); Assert.That(match.MatchId, Is.EqualTo(matchId)); Assert.That(match.Region, Is.EqualTo(client.Region)); }
public async Task CreateTournamentCodeAsyncTest_WithArguments() { IRiotClient client = new RiotClient(Region.NA, TournamentApiKey); var codes = await client.CreateTournamentCodeAsync(3092, 1, new List<long> { 35870943L, 32153637L, 31220286L, 37431081L, 20934656L, 30545906L, 32550537L, 38722060L }, MapType.HOWLING_ABYSS, PickType.ALL_RANDOM, SpectatorType.LOBBYONLY, 4, "test"); Assert.That(codes, Is.Not.Null.And.Not.Empty); Assert.That(codes.Count, Is.EqualTo(1)); }
public async Task RateLimitTest_ShouldReturnNull() { IRiotClient client = new RiotClient(); client.Settings.RetryOnRateLimitExceeded = false; client.Settings.ThrowOnError = false; await MaxOutRateLimit(client); var league = await client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5); Assert.That(league, Is.Null); }
public async Task GetMatchAsyncTest() { IRiotClient client = new RiotClient(); const long matchId = 2032332497L; var match = await client.GetMatchAsync(matchId); Assert.That(match, Is.Not.Null); Assert.That(match.MatchId, Is.EqualTo(matchId)); Assert.That(match.Region, Is.EqualTo(client.Region)); Assert.That(match.Timeline, Is.Null); }
public async Task GetStatsSummaryAsyncTest_WithSeason() { IRiotClient client = new RiotClient(); var stats = await client.GetStatsSummaryAsync(35870943L, Season.SEASON2014); Assert.That(stats, Is.Not.Null); Assert.That(stats.PlayerStatSummaries, Is.Not.Null.And.Not.Empty); foreach (var summary in stats.PlayerStatSummaries) Assert.That(summary.ModifyDate, Is.LessThan(new DateTime(2015, 2, 1, 0, 0, 0, DateTimeKind.Utc))); Assert.That(stats.SummonerId, Is.EqualTo(35870943L)); }
public async Task GetChallengerLeagueAsyncTest() { IRiotClient client = new RiotClient(); var league = await client.GetChallengerLeagueAsync(RankedQueue.RANKED_SOLO_5x5); Assert.That(league, Is.Not.Null); Assert.That(league.Entries.Count, Is.GreaterThan(1)); Assert.That(league.Name, Is.Not.Null.And.Not.Empty); Assert.That(league.Queue, Is.EqualTo(RankedQueue.RANKED_SOLO_5x5)); Assert.That(league.Tier, Is.EqualTo(Tier.CHALLENGER)); }
public async Task GetRankedStatsAsyncTest_WithSeason() { IRiotClient client = new RiotClient(); var stats = await client.GetRankedStatsAsync(35870943L, Season.SEASON2014); Assert.That(stats, Is.Not.Null); Assert.That(stats.Champions, Is.Not.Null.And.Not.Empty); Assert.That(stats.SummonerId, Is.EqualTo(35870943L)); Assert.That(stats.ModifyDate.Kind, Is.EqualTo(DateTimeKind.Utc)); Assert.That(stats.ModifyDate, Is.GreaterThan(default(DateTime)).And.LessThan(new DateTime(2015, 2, 1, 0, 0, 0, DateTimeKind.Utc))); }
public async Task RateLimitTest_ShouldRetry() { IRiotClient client = new RiotClient(); client.Settings.MaxRequestAttempts = 2; client.Settings.RetryOnRateLimitExceeded = true; client.Settings.ThrowOnError = true; for (var i = 0; i < 11; ++i) { var league = await client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5); Assert.That(league, Is.Not.Null); } }
public async Task GetStaticChampionsAsyncTest_WithSelectedFields() { IRiotClient client = new RiotClient(); var championList = await client.GetStaticChampionsAsync(champListData: new[] { "AllyTips", "Blurb" }); Assert.That(championList.Data.Count, Is.GreaterThan(0)); var champion = championList.Data.Values.First(); Assert.That(champion.AllyTips, Is.Not.Null.And.No.Empty); Assert.That(champion.Blurb, Is.Not.Null.And.No.Empty); Assert.That(champion.EnemyTips, Is.Null.Or.Empty); }
public async Task GetCurrentGameBySummonerIdAsyncTest() { IRiotClient client = new RiotClient(); // In order to get a summoner ID that is guaranteed to be in a game, we need to get a featured game. var featuredGameList = await client.GetFeaturedGamesAsync(); var featuredGame = featuredGameList.GameList.First(); var summonerName = featuredGame.Participants.First().SummonerName; var summoner = await client.GetSummonerBySummonerNameAsync(summonerName); var game = await client.GetCurrentGameBySummonerIdAsync(summoner.Id); Assert.That(game, Is.Not.Null); // Apparently the featured games are all blind pick now because we ware between seasons. /*Assert.That(game.BannedChampions, Is.Not.Null.And.Not.Empty); var bannedChampion = game.BannedChampions.First(); Assert.That(bannedChampion.ChampionId, Is.GreaterThan(0)); Assert.That(bannedChampion.PickTurn, Is.GreaterThan(0)); Assert.That(game.BannedChampions.Any(c => c.TeamId == TeamSide.Team2));*/ Assert.That(game.GameId, Is.GreaterThan(0)); Assert.That(game.GameLength, Is.GreaterThan(TimeSpan.Zero)); Assert.That(game.GameMode, Is.EqualTo(GameMode.CLASSIC).Or.EqualTo(GameMode.ARAM)); Assert.That(game.GameQueueConfigId, Is.EqualTo(QueueType.TEAM_BUILDER_DRAFT_RANKED_5x5) .Or.EqualTo(QueueType.TEAM_BUILDER_DRAFT_UNRANKED_5x5) .Or.EqualTo(QueueType.RANKED_SOLO_5x5) .Or.EqualTo(QueueType.NORMAL_5x5_DRAFT) .Or.EqualTo(QueueType.ARAM_5x5)); Assert.That(game.GameStartTime.Kind, Is.EqualTo(DateTimeKind.Utc)); Assert.That(game.GameStartTime, Is.LessThan(DateTime.UtcNow).And.GreaterThan(DateTime.UtcNow.AddHours(-2))); Assert.That(game.GameType, Is.EqualTo(GameType.MATCHED_GAME)); Assert.That(game.MapId, Is.GreaterThan(0)); Assert.That(game.Observers, Is.Not.Null); Assert.That(game.Observers.EncryptionKey, Is.Not.Null.And.Not.Empty); Assert.That(game.Participants, Is.Not.Null.And.Not.Empty); var participant = game.Participants.First(); Assert.That(participant.Bot, Is.False); Assert.That(participant.ChampionId, Is.GreaterThan(0)); Assert.That(participant.Masteries, Is.Not.Null.And.Not.Empty); var mastery = participant.Masteries.First(); Assert.That(mastery.MasteryId, Is.GreaterThan(0)); Assert.That(mastery.Rank, Is.GreaterThan(0)); Assert.That(participant.ProfileIconId, Is.GreaterThan(0)); Assert.That(participant.Runes, Is.Not.Null.And.Not.Empty); var rune = participant.Runes.First(); Assert.That(rune.Count, Is.GreaterThan(0)); Assert.That(rune.Rank, Is.GreaterThan(0)); Assert.That(rune.RuneId, Is.GreaterThan(0)); Assert.That(participant.Spell1Id, Is.GreaterThan(0)); Assert.That(participant.Spell2Id, Is.GreaterThan(0)); Assert.That(participant.SummonerId, Is.GreaterThan(0)); Assert.That(participant.SummonerName, Is.Not.Null.And.Not.Empty); Assert.That(game.Participants.Any(p => p.TeamId == TeamSide.Team2)); Assert.That(game.PlatformId, Is.EqualTo(client.PlatformId)); }
public async Task GetStaticChampionsAsyncTest_WithSelectedFields() { IRiotClient client = new RiotClient(); var championList = await client.GetStaticChampionsAsync(tags : new[] { "AllyTips", "Blurb" }); Assert.That(championList.Data.Count, Is.GreaterThan(0)); var champion = championList.Data.Values.First(); Assert.That(champion.AllyTips, Is.Not.Null.And.No.Empty); Assert.That(champion.Blurb, Is.Not.Null.And.No.Empty); Assert.That(champion.EnemyTips, Is.Null.Or.Empty); }
public async Task GetStaticMasteriesAsyncTest_WithLocale() { IRiotClient client = new RiotClient(); var masteryList = await client.GetStaticMasteriesAsync(Locale.en_SG); Assert.That(masteryList.Data.Count, Is.GreaterThan(0)); Assert.That(masteryList.Type, Is.Not.Null.And.Not.Empty); Assert.That(masteryList.Version, Is.Not.Null.And.Not.Empty); var mastery = masteryList.Data["6131"]; Assert.That(mastery.Name, Is.EqualTo("Vampirism")); }
public async Task GetRankedStatsAsyncTest() { IRiotClient client = new RiotClient(); var stats = await client.GetRankedStatsAsync(35870943L); Assert.That(stats, Is.Not.Null); Assert.That(stats.Champions, Is.Not.Null.And.Not.Empty); Assert.That(stats.SummonerId, Is.EqualTo(35870943L)); Assert.That(stats.ModifyDate.Kind, Is.EqualTo(DateTimeKind.Utc)); Assert.That(stats.ModifyDate, Is.GreaterThan(default(DateTime)).And.LessThan(DateTime.UtcNow)); // There should be one entry with champion ID 0 that represents the combined stats for all champions. Assert.That(stats.Champions.Any(c => c.Id == 0)); }
public async Task GetLeagueEntriesBySummonerIdAsync() { IRiotClient client = new RiotClient(); List <LeagueEntry> leagueEntries = await client.GetLeagueEntriesBySummonerIdAsync(encryptedSummonerId); Assert.That(leagueEntries, Is.Not.Null); var leagueEntry = leagueEntries.First(); Assert.That(leagueEntry.LeagueId, Is.Not.Null.And.Not.Empty); Assert.That(leagueEntry.QueueType, Is.Not.Null.And.Not.Empty); Assert.That(leagueEntry.Tier, Is.Not.EqualTo(Tier.CHALLENGER)); Assert.That(leagueEntry.Rank, Is.Not.Null.And.Not.Empty); }
static async Task TestAsync(long MatchID) { IRiotClient client = new RiotClient(new RiotClientSettings { ApiKey = "############" // Replace this with your API key, of course. }); cli = client; Match match = await client.GetMatchAsync(MatchID, PlatformId.NA1).ConfigureAwait(false); T1 = match; }
public async Task GetLeagueEntriesBySummonerIdsAsyncTest() { IRiotClient client = new RiotClient(); var summonerIds = new[] { 35870943L, 34172230L }; var leagues = await client.GetLeagueEntriesBySummonerIdsAsync(summonerIds); Assert.That(leagues, Is.Not.Null); foreach (var id in summonerIds) Assert.That(leagues.ContainsKey(id.ToString(CultureInfo.InvariantCulture))); var league = leagues.Values.First().First(); Assert.That(league.Entries.Count, Is.EqualTo(1)); Assert.That(league.Name, Is.Not.Null.And.Not.Empty); }
public async Task GetStaticItemsAsyncTest_WithSelectedFields() { IRiotClient client = new RiotClient(); var itemList = await client.GetStaticItemsAsync(tags : new[] { nameof(StaticItem.Maps), nameof(StaticItem.SanitizedDescription) }); Assert.That(itemList.Data, Is.Not.Null); Assert.That(itemList.Data.Count, Is.GreaterThan(0)); var item = itemList.Data.Values.First(); Assert.That(item.Maps, Is.Not.Null.And.Not.Empty); Assert.That(item.SanitizedDescription, Is.Not.Null.And.Not.Empty); Assert.That(item.Image.Full, Is.Null.Or.Empty); }
public async Task GetLeagueEntriesByTeamIdsAsyncTest() { IRiotClient client = new RiotClient(); var teamIds = new[] { "TEAM-3503e740-b492-11e3-809d-782bcb4d0bb2", "TEAM-2a88df50-da0d-11e3-b43f-782bcb4d1861" }; var leagues = await client.GetLeagueEntriesByTeamIdsAsync(teamIds); Assert.That(leagues, Is.Not.Null); foreach (var id in teamIds) Assert.That(leagues.ContainsKey(id)); var league = leagues.Values.First().First(); Assert.That(league.Entries.Count, Is.EqualTo(1)); Assert.That(league.Name, Is.Not.Null.And.Not.Empty); }
public async Task GetChampionMasteryAsyncTest() { IRiotClient client = new RiotClient(); var championMastery = await client.GetChampionMasteryAsync(encryptedSummonerId, 412L); // Thresh Assert.That(championMastery, Is.Not.Null); Assert.That(championMastery.ChampionId, Is.EqualTo(412L)); Assert.That(championMastery.LastPlayTime.Kind, Is.EqualTo(DateTimeKind.Utc)); Assert.That(championMastery.LastPlayTime, Is.GreaterThan(new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc)).And.LessThanOrEqualTo(DateTime.UtcNow)); Assert.That(championMastery.ChampionLevel, Is.AtLeast(1), "Invalid champion level."); Assert.That(championMastery.ChampionPoints, Is.AtLeast(1), "Invalid number of champion points."); // Riot is returning wrong data for no known reason. It returns the summoner id encrypted in a different way than the other endpoints. Check this when v4 is totally active and v3 deprectated //Assert.That(championMastery.SummonerId, Is.EqualTo(EncryptedSummonerId)); }
public async Task GetStaticProfileIconsAsyncTest() { IRiotClient client = new RiotClient(); StaticProfileIconData iconList = await client.GetStaticProfileIconsAsync(); Assert.That(iconList.Data.Count, Is.GreaterThan(0)); Assert.That(iconList.Type, Is.EqualTo("profileicon")); Assert.That(iconList.Version, Is.Not.Null.And.Not.Empty); StaticProfileIcon icon = iconList.Data.Values.First(); Assert.That(icon.Id, Is.GreaterThan(0)); Assert.That(icon.Image, Is.Not.Null); }
public async Task GetShardStatusAsyncTest() { RiotClient.DefaultPlatformId = PlatformId.EUN1; IRiotClient client = new RiotClient(); ShardStatus shard = await client.GetShardStatusAsync(); Assert.That(shard, Is.Not.Null); Assert.That(shard.Name, Is.EqualTo("EU Nordic & East")); Assert.That(shard.Slug, Is.EqualTo("eune")); Assert.That(shard.RegionTag, Is.EqualTo("eun1")); Assert.That(shard.Hostname, Is.Not.Null.And.Not.Empty); Assert.That(shard.Services, Is.Not.Null.And.Not.Empty); Assert.That(shard.Locales, Is.Not.Null.And.Not.Empty); }
public async Task RateLimitTest_ShouldRetry() { IRiotClient client = new RiotClient(); client.Settings.MaxRequestAttempts = 2; client.Settings.RetryOnRateLimitExceeded = true; client.Settings.ThrowOnError = true; for (var i = 0; i < 21; ++i) { var league = await client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5); Assert.That(league, Is.Not.Null, "Failed to get league: " + i); } }
public async Task RateLimitTest_ShouldApplyRateLimiter_WithConcurrentRequests() { await Task.Delay(TimeSpan.FromMinutes(2)); // in case a previous test maxed out the limit RiotClient.RateLimiter = new RateLimiter(); void onRateLimitExceeded(object o, RetryEventArgs e) { if (e.Response != null) { Assert.Fail("Rate limit was exceeded! Proactive rate limiting failed."); } } IRiotClient client = new RiotClient(); client.Settings.RetryOnRateLimitExceeded = true; client.RateLimitExceeded += onRateLimitExceeded; // Send one request in advance so the client can get the rate limits. await client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5); var tasks = new List <Task <LeagueList> >(); for (var i = 0; i < 59; ++i) { tasks.Add(Task.Run(() => client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5))); } var allTask = Task.WhenAll(tasks); var finishedTask = await Task.WhenAny(allTask, Task.Delay(60000)); if (finishedTask == allTask) { var failedTask = tasks.FirstOrDefault(t => t.IsFaulted); if (failedTask != null) { Assert.Fail(failedTask.Exception?.ToString()); } var leagues = allTask.Result; for (var i = 0; i < tasks.Count; ++i) { Assert.That(leagues[i], Is.Not.Null, "Failed to get league: " + i); } } else { var completedCount = tasks.Count(t => t.IsCompleted); Assert.Fail($"Timed out waiting for tasks ({completedCount}/{tasks.Count} tasks completed)"); } }
public async Task GetStaticSummonerSpellsAsyncTest() { IRiotClient client = new RiotClient(); var spellList = await client.GetStaticSummonerSpellsAsync(tags : new[] { "all" }); Assert.That(spellList.Data.Count, Is.GreaterThan(0)); Assert.That(spellList.Type, Is.Not.Null.And.Not.Empty); Assert.That(spellList.Version, Is.Not.Null.And.Not.Empty); var spell = spellList.Data["SummonerBoost"]; Assert.That(spell.Id, Is.GreaterThan(0)); Assert.That(spell.Cooldown, Is.Not.Null.And.Not.Empty); foreach (var cooldown in spell.Cooldown) { Assert.That(cooldown, Is.GreaterThan(0)); } Assert.That(spell.CooldownBurn, Is.Not.Null.And.Not.Empty); Assert.That(spell.Cost, Is.Not.Null.And.Not.Empty); Assert.That(spell.CostBurn, Is.Not.Null.And.Not.Empty); Assert.That(spell.CostType, Is.Not.Null.And.Not.Empty); Assert.That(spell.Description, Is.Not.Null.And.Not.Empty); Assert.That(spellList.Data.Values.Any(s => s.Effect != null && s.Effect.Count > 0)); Assert.That(spellList.Data.Values.Any(s => s.EffectBurn != null && s.EffectBurn.Count > 0)); Assert.That(spell.Image, Is.Not.Null); Assert.That(spell.Key, Is.Not.Null.And.Not.Empty); Assert.That(spell.MaxRank, Is.GreaterThan(0)); Assert.That(spell.Modes, Is.Not.Null.And.Not.Empty); Assert.That(spell.Modes.First(), Is.Not.Null.And.Not.Empty); Assert.That(spell.Name, Is.Not.Null.And.Not.Empty); Assert.That(spell.Range, Is.Not.Null.And.Not.Empty); Assert.That(spell.RangeBurn, Is.Not.Null.And.Not.Empty); Assert.That(spell.Resource, Is.Not.Null.And.Not.Empty); Assert.That(spell.SanitizedDescription, Is.Not.Null.And.Not.Empty); Assert.That(spell.SanitizedTooltip, Is.Not.Null.And.Not.Empty); Assert.That(spell.Tooltip, Is.Not.Null.And.Not.Empty); Assert.That(spell.Vars, Is.Not.Null); var spellVar = spell.Vars.First(); Assert.That(spellVar.Coeff, Is.Not.Null.And.Not.Empty); Assert.That(spellVar.Key, Is.Not.Null.And.Not.Empty); Assert.That(spellVar.Link, Is.Not.Null.And.Not.Empty); // The key should NOT be an integer var key = spellList.Data.Keys.First(); var isInteger = int.TryParse(key, out int id); Assert.That(isInteger, Is.False, "Champs are listed by ID, but should be listed by key."); }
public async Task GetMatchListByAccountIdAsyncTest_WithDateFilters() { IRiotClient client = new RiotClient(); var beginTime = new DateTime(2015, 6, 1, 0, 0, 0, DateTimeKind.Utc); var endTime = new DateTime(2015, 6, 7, 0, 0, 0, DateTimeKind.Utc); var matchList = await client.GetMatchListByAccountIdAsync(48555045L, beginTime : beginTime, endTime : endTime); Assert.That(matchList, Is.Not.Null); Assert.That(matchList.Matches, Is.Not.Null.And.Not.Empty); for (var i = 0; i < matchList.Matches.Count; ++i) { Assert.That(matchList.Matches[i].Timestamp, Is.GreaterThanOrEqualTo(beginTime), $"Match {i} was before the begin time."); Assert.That(matchList.Matches[i].Timestamp, Is.LessThanOrEqualTo(endTime), $"Match {i} was after the end time."); } }
public async Task GetStaticChampionsAsyncTest_IndexedById() { IRiotClient client = new RiotClient(); var championList = await client.GetStaticChampionsAsync(dataById : true); Assert.That(championList.Data.Count, Is.GreaterThan(0)); Assert.That(championList.Type, Is.Not.Null.And.Not.Empty); Assert.That(championList.Version, Is.Not.Null.And.Not.Empty); // The key should be an integer var key = championList.Data.Keys.First(); var isInteger = int.TryParse(key, out int id); Assert.That(isInteger, Is.True, "Champs are listed by key, but should be listed by ID."); }
public async Task GetStaticRealmAsyncTest_EUW() { IRiotClient client = RiotClient.ForPlatform(PlatformId.EUW1); var realm = await client.GetStaticRealmAsync(); Assert.That(realm, Is.Not.Null); Assert.That(realm.Cdn, Is.Not.Null.And.Not.Empty); Assert.That(realm.Css, Is.Not.Null.And.Not.Empty); Assert.That(realm.Dd, Is.Not.Null.And.Not.Empty); Assert.That(realm.L, Is.EqualTo(Locale.en_GB)); Assert.That(realm.Lg, Is.Not.Null.And.Not.Empty); Assert.That(realm.N, Is.Not.Null.And.Not.Empty); Assert.That(realm.ProfileIconMax, Is.GreaterThan(0)); Assert.That(realm.V, Is.Not.Null.And.Not.Empty); }
public void Example3() { IRiotClient riotClient = new RiotClient("your api key here"); //get challeger tier league for ranked solo 5x5 var challengers = riotClient.League.GetChallengerTierLeagues(RiotApiConfig.Regions.EUNE, Enums.GameQueueType.RANKED_SOLO_5x5); //get top 5 leaderboard using LINQ var top5 = challengers.Entries.OrderByDescending(x => x.LeaguePoints).Take(5).ToList(); //Print top 5 leaderboard top5.ForEach( topEntry => Console.WriteLine( $"{topEntry.PlayerOrTeamName} - wins:{topEntry.Wins} loss:{topEntry.Losses} points:{topEntry.LeaguePoints}")); }
public static void ClientStart(RiotClient client, int configPort) { if (ClientIsRunning(client)) { return; } var startArgs = new ProcessStartInfo { FileName = GetRiotClientPath(), Arguments = "--client-config-url=\"http://127.0.0.1:" + configPort + "\" --launch-product=" + GetClientProductName(client) + " --launch-patchline=live" }; Process.Start(startArgs); }
public async Task GetStaticMasteriesAsyncTest_WithSelectedFields() { IRiotClient client = new RiotClient(); var masteryList = await client.GetStaticMasteriesAsync(tags : new[] { nameof(StaticMasteryList.Tree), nameof(StaticMastery.MasteryTree), }); Assert.That(masteryList.Data.Count, Is.GreaterThan(0)); Assert.That(masteryList.Tree, Is.Not.Null); Assert.That(masteryList.Data.Values.Any(m => m.MasteryTree != MastertyTreeType.Ferocity)); Assert.That(masteryList.Data.Values.All(m => m.Ranks == 0)); }
public async Task GetStaticMapsAsyncTest() { IRiotClient client = new RiotClient(); var mapList = await client.GetStaticMapsAsync(); Assert.That(mapList.Data, Is.Not.Null.And.Not.Empty); Assert.That(mapList.Type, Is.Not.Null.And.Not.Empty); Assert.That(mapList.Version, Is.Not.Null.And.Not.Empty); var map = mapList.Data.Values.First(); Assert.That(map.Image, Is.Not.Null); Assert.That(map.MapId, Is.GreaterThan(0)); Assert.That(map.MapName, Is.Not.Null.And.Not.Empty); // The Riot API never seems to set this property. This line is commented so the test passes while we wait for Riot to fix it. //Assert.That(map.UnpurchasableItemList, Is.Not.Null.And.Not.Empty); }
// GET: Profile/Details/5 public ActionResult Details() { ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); var mail = user.Email; var aaaa = tester.GetMany(m => m.email == mail); var a = tester.GetById(aaaa.First().Id); IRiotClient riotClient = new RiotClient("f5e474de-885a-477a-8b74-fa16f5915741"); var cham = riotClient.LolStatus.GetShardStatusByRegion(RiotApiConfig.Regions.EUW).Services.First(); ViewBag.statut = cham.Status.ToString(); return(View(a)); }
public async Task GetStaticRunesAsyncTest_WithSelectedFields() { IRiotClient client = new RiotClient(); var runeList = await client.GetStaticRunesAsync(tags : new[] { nameof(StaticRune.Image), nameof(StaticRune.SanitizedDescription), }); Assert.That(runeList.Data.Count, Is.GreaterThan(0)); var rune = runeList.Data.Values.First(); Assert.That(rune.Image.Full, Is.Not.Null.And.Not.Empty); Assert.That(rune.SanitizedDescription, Is.Not.Null.And.Not.Empty); Assert.That(rune.Tags, Is.Null.Or.Empty); }
public async Task GetMatchListByAccountIdAsyncTest() { IRiotClient client = new RiotClient(); MatchList matchList = await client.GetMatchListByAccountIdAsync(48555045L, beginIndex : 1, endIndex : 3); Assert.That(matchList, Is.Not.Null); Assert.That(matchList.Matches, Is.Not.Null.And.Not.Empty); var match = matchList.Matches.First(); Assert.That(match.GameId, Is.GreaterThan(0)); Assert.That(match.PlatformId, Is.EqualTo(client.PlatformId)); Assert.That(matchList.StartIndex, Is.EqualTo(1)); Assert.That(matchList.EndIndex, Is.EqualTo(3)); Assert.That(matchList.TotalGames, Is.GreaterThan(0)); }
public async Task GetChampionMasteriesAsyncTest() { IRiotClient client = new RiotClient(); var championMasteries = await client.GetChampionMasteriesAsync(34172230L); Assert.That(championMasteries, Is.Not.Null.And.Not.Empty); foreach (var championMastery in championMasteries) { Assert.That(championMastery, Is.Not.Null); Assert.That(championMastery.ChampionId, Is.AtLeast(1), "Invalid champion ID."); Assert.That(championMastery.LastPlayTime, Is.GreaterThan(new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc)).And.LessThanOrEqualTo(DateTime.UtcNow)); Assert.That(championMastery.ChampionLevel, Is.AtLeast(1), "Invalid champion level (champion ID: " + championMastery.ChampionId + "."); Assert.That(championMastery.ChampionPoints, Is.AtLeast(1), "Invalid number of champion points (champion ID: " + championMastery.ChampionId + "."); Assert.That(championMastery.PlayerId, Is.EqualTo(34172230L)); } }
public async Task GetCurrentGameBySummonerIdAsyncTest() { // This is just an alias for GetActiveGameBySummonerIdAsync(), so just test that the alias works IRiotClient client = new RiotClient(); // In order to get a summoner ID that is guaranteed to be in a game, we need to get a featured game. var featuredGameList = await client.GetFeaturedGamesAsync(); var featuredGame = featuredGameList.GameList.First(); var summonerName = featuredGame.Participants.First().SummonerName; var summoner = await client.GetSummonerBySummonerNameAsync(summonerName); var game = await client.GetCurrentGameBySummonerIdAsync(summoner.Id); Assert.That(game, Is.Not.Null); Assert.That(game.GameId, Is.GreaterThan(0)); }
private static void SaveData(string inputDirectory, string outputDirectory) { bool timeline = true; string key = ConfigurationManager.AppSettings["APIKey"]; RiotClient riotClient = RiotApiLoader.CreateHttpClient(key); IEnumerable <string> filenames = Directory.EnumerateFiles(inputDirectory, "*", SearchOption.AllDirectories); File.WriteAllText(outputDirectory + "matches.csv", "Id,Duration,Region,Patch,Queue" + Environment.NewLine); File.WriteAllText(outputDirectory + "teams.csv", "MatchId,Id,Winner" + Environment.NewLine); File.WriteAllText(outputDirectory + "bans.csv", "MatchId,ChampionId" + Environment.NewLine); File.WriteAllText(outputDirectory + "participants.csv", "MatchId,TeamId,ParticipantId,ChampionId,HighestAchievedSeasonTier,Lane,Role,Assists,Deaths,FirstBloodKill,GoldEarned,Item0,Item1,Item2,Item3,Item4,Item5,Item6,Kills,MagicDamageDealt,MagicDamageDealtToChampions,MagicDamageTaken,MinionsKilled,NeutralMinionsKilled,PhysicalDamageDealt,PhysicalDamageDealtToChampions,PhysicalDamageTaken,SightWardsBoughtInGame,TotalDamageDealt,TotalDamageDealtToChampions,TotalDamageTaken,TotalHeal,TotalTimeCrowdControlDealt,TotalUnitsHealed,TrueDamageDealt,TrueDamageDealtToChampions,TrueDamageTaken,VisionWardsBoughtInGame,WardsKilled,WardsPlaced,CreepsPerMinDeltas010,GoldPerMinDeltas010,CreepsPerMinDeltas1020,GoldPerMinDeltas1020,CreepsPerMinDeltas2030,GoldPerMinDeltas2030,CreepsPerMinDeltas30,GoldPerMinDeltas30,SummonerId,SummonerName" + Environment.NewLine); File.WriteAllText(outputDirectory + "events.csv", "MatchId,ParticipantId,EventType,ItemAfter,ItemBefore,ItemId,LevelUpType,SkillSlot,Timestamp" + Environment.NewLine); File.WriteAllText(outputDirectory + "participantFrames.csv", "MatchId,ParticipantId,CurrentGold,Level,MinionsKilled,TotalGold,Xp,Timestamp" + Environment.NewLine); File.WriteAllText(outputDirectory + "error.csv", "MatchId,Message,StackTrace,Timestamp" + Environment.NewLine); foreach (string inputFileName in filenames) { string matchIdsString = File.ReadAllText(inputFileName); string[] parts = inputFileName.Split('\\'); string region = parts[parts.Length - 1].Replace(".json", ""); foreach (string s in matchIdsString.Split(',', '[', ']', '\r', '\n', ' ', '\t')) { if (string.IsNullOrEmpty(s)) { continue; } long matchId = long.Parse(s); try { MatchInfo match = GetMatchInfo(region, matchId, timeline, key, riotClient); File.AppendAllText(outputDirectory + "matches.csv", match.Match.ToString() + Environment.NewLine); File.AppendAllLines(outputDirectory + "teams.csv", match.Teams.Select(t => t.ToString())); File.AppendAllLines(outputDirectory + "bans.csv", match.Bans.Select(b => b.ToString())); File.AppendAllLines(outputDirectory + "participants.csv", match.Participants.Select(p => p.ToString())); File.AppendAllLines(outputDirectory + "events.csv", match.Events.Select(e => e.ToString())); File.AppendAllLines(outputDirectory + "participantFrames.csv", match.ParticipantFrames.Select(pf => pf.ToString())); Thread.Sleep(1500); } catch (Exception e) { File.AppendAllText(outputDirectory + "error.csv", "\"" + matchId + "\",\"" + DateTime.Now + "\",\"" + e.Message + "\",\"" + e.StackTrace + "\""); Console.WriteLine(matchId + "\n" + e.Message + "\n" + e.StackTrace); } } } }
private static string GetClientProcessName(RiotClient client) { switch (client) { case RiotClient.LeagueOfLegends: return("LeagueClient"); case RiotClient.Runeterra: return("LoR"); case RiotClient.Valorant: return("VALORANT-Win64-Shipping"); default: throw new InvalidOperationException(); } }
private static string GetClientProductName(RiotClient client) { switch (client) { case RiotClient.LeagueOfLegends: return("league_of_legends"); case RiotClient.Runeterra: return("bacon"); case RiotClient.Valorant: return("valorant"); default: throw new InvalidOperationException(); } }
public async Task GetStaticChampionsAsyncTest() { IRiotClient client = new RiotClient(); var championList = await client.GetStaticChampionsAsync(tags : new[] { "all" }); Assert.That(championList.Data.Count, Is.GreaterThan(0), "Missing data"); Assert.That(championList.Format, Is.Not.Null.And.Not.Empty, "Missing format"); Assert.That(championList.Keys.Count, Is.GreaterThan(0), "Missing keys"); Assert.That(championList.Type, Is.Not.Null.And.Not.Empty, "Missing type"); Assert.That(championList.Version, Is.Not.Null.And.Not.Empty, "Missing version"); // The key should NOT be an integer var key = championList.Data.Keys.First(); var isInteger = int.TryParse(key, out int id); Assert.That(isInteger, Is.False, "Champs are listed by ID, but should be listed by key."); }
public async Task Game(string region, [Remainder] string summonerName) { Platforms platform = (Platforms)Enum.Parse(typeof(Platforms), region.ToUpper()); var riotClient = new RiotClient(OptionManager.RiotKey); var champions = new RiotData().Champions; var summoner = riotClient.Summoner.GetSummonerByName(summonerName, platform); var match = riotClient.Specate.GameBySummoner(platform, summoner.SummonerId); var builder = Builders.BaseBuilder("", "", Color.DarkBlue, new EmbedAuthorBuilder().WithName(summonerName + "'s game"), ""); TimeSpan time = new TimeSpan(0, 0, (int)match.GameLength); builder.AddField($"Information", $"**Map: **{match.MapId}\n**Time: **{Math.Round(time.TotalMinutes,2)} minutes\n**Mode: **{match.GameMode}"); for (int i = 1; i < 3; i++) { string bans1 = ""; foreach (var matchBannedChampion in match.BannedChampions) { if (matchBannedChampion.TeamId == i * 100) { try { bans1 += champions.FirstOrDefault(x => x.ChampionId == matchBannedChampion.ChampionId).name + ", "; } catch { bans1 += "None, "; } } } bans1 = bans1.Remove(bans1.Length - 2, 2); builder.AddField("Bans Team " + i, bans1); string names = ""; string championsNames = ""; foreach (var currentGameParticipant in match.Participants.Where(x => x.TeamId == i * 100).ToList()) { names += currentGameParticipant.SummonerName + "\n"; championsNames += champions.FirstOrDefault(x => x.ChampionId == currentGameParticipant.ChampionId)?.name + "\n"; } builder.AddInlineField("Summoners", names); builder.AddInlineField("Champion", championsNames); } await ReplyAsync("", embed : builder.Build()); }
public async Task GetStaticSummonerSpellsAsyncTest_WithSelectedFields() { IRiotClient client = new RiotClient(); var spellList = await client.GetStaticSummonerSpellsAsync(tags : new[] { nameof(StaticSummonerSpell.Cooldown), nameof(StaticSummonerSpell.CooldownBurn), }); Assert.That(spellList.Data.Count, Is.GreaterThan(0)); var spell = spellList.Data.Values.First(); Assert.That(spell.Cooldown, Is.Not.Null.And.Not.Empty); Assert.That(spell.CooldownBurn, Is.Not.Null.And.Not.Empty); Assert.That(spell.Cost, Is.Null.Or.Empty); }
public async Task RateLimitTest_ShouldProcessRequestsInOrder() { await Task.Delay(TimeSpan.FromMinutes(2)); // in case a previous test maxed out the limit IRiotClient client = new RiotClient(new RateLimiter()); client.Settings.RetryOnRateLimitExceeded = true; client.Settings.RetryOnConnectionFailure = false; client.Settings.RetryOnServerError = false; client.Settings.RetryOnTimeout = false; client.RateLimitExceeded += (o, e) => { if (e.Response != null) { Assert.Fail("Rate limit was exceeded! Proactive rate limiting failed."); } }; // Send one request in advance so the client can get the rate limits. await client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5); await Task.Delay(1000); await MaxOutRateLimit(client); var tasks = new List <Task <LeagueList> >(); for (var i = 0; i < 30; ++i) { tasks.Add(client.GetMasterLeagueAsync(RankedQueue.RANKED_SOLO_5x5)); } await Task.Delay(1800); var failedTask = tasks.FirstOrDefault(t => t.IsFaulted); if (failedTask != null) { Assert.Fail(failedTask.Exception?.ToString()); } var expectedCompletedCount = tasks.Take(20).Count(t => t.IsCompleted); var unexpectedCompletedCount = tasks.Skip(20).Count(t => t.IsCompleted); Assert.That(expectedCompletedCount, Is.EqualTo(20), $"Tasks were completed out of order - {expectedCompletedCount} of the first 20 were completed. ({unexpectedCompletedCount} of the last 10)"); Assert.That(unexpectedCompletedCount, Is.EqualTo(0), $"Extra tasks were completed - {unexpectedCompletedCount}/10."); }