Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TFT Endpoints : Issue#640 #645

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added tft endpoint for match, summoner, and league.
Nolan Bradshaw committed Jan 29, 2020
commit 1fc3bcaa319586c2b53c0cdf196c5029362ff704
2 changes: 2 additions & 0 deletions RiotSharp.Test/CommonTestBase.cs
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@ public class CommonTestBase
public static string Summoner3Name = "xsunx";
public static Region Summoner3Region = (Region)Enum.Parse(typeof(Region), "Ru");

public static Region TftSummonerRegion = (Region)Enum.Parse(typeof(Region), "Americas");

/// <summary>
/// Ensures that test returns data (Shows test warnings for 404 status exceptions)
/// </summary>
130 changes: 130 additions & 0 deletions RiotSharp.Test/RiotApiTest.cs
Original file line number Diff line number Diff line change
@@ -30,6 +30,19 @@ public void GetSummonerBySummonerIdAsync_ExistingId_ReturnsSummoner()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftSummonerBySummonerIdAsync_ExistingId_ReturnsSummoner()
{
EnsureCredibility(() =>
{
var summoner = Api.Summoner.GetTftSummonerBySummonerIdAsync(Summoner1And2Region,
Summoner1Id);

Assert.AreEqual(Summoner1Name, summoner.Result.Name);
});
}


[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
@@ -44,6 +57,19 @@ public void GetSummonerByAccountIdAsync_ExistingAccountId_ReturnsSummoner()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftSummonerByAccountIdAsync_ExistingAccountId_ReturnsSummoner()
{
EnsureCredibility(() =>
{
var summoner = Api.Summoner.GetTftSummonerByAccountIdAsync(Summoner1And2Region,
Summoner1AccountId);

Assert.AreEqual(Summoner1Name, summoner.Result.Name);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetSummonerByNameAsync_ExistingName_ReturnsSummoner()
@@ -57,6 +83,19 @@ public void GetSummonerByNameAsync_ExistingName_ReturnsSummoner()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftSummonerByNameAsync_ExistingName_ReturnsSummoner()
{
EnsureCredibility(() =>
{
var summoner = Api.Summoner.GetTftSummonerByNameAsync(Summoner1And2Region,
Summoner1Name);

Assert.AreEqual(Summoner1Id, summoner.Result.Id);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetSummonerBySummonerPuuidAsync_ExistingId_ReturnsSummoner()
@@ -69,6 +108,19 @@ public void GetSummonerBySummonerPuuidAsync_ExistingId_ReturnsSummoner()
Assert.AreEqual(Summoner1Name, summoner.Result.Name);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftSummonerByPuuidAsync_ExistingId_ReturnsSummoner()
{
EnsureCredibility(() =>
{
var summoner = Api.Summoner.GetTftSummonerByPuuidAsync(Summoner1And2Region,
Summoner1Puuid);

Assert.AreEqual(Summoner1Name, summoner.Result.Name);
});
}
#endregion

#region Champion Tests
@@ -104,6 +156,20 @@ public void GetLeagueEntriesBySummonerAsync_Test()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftLeagueEntriesBySummonerAsync_Test()
{
EnsureCredibility(() =>
{
// TODO: Properly implement encrypted SummonerId tests
return;
var leagues = Api.League.GetTftLeagueEntriesBySummonerAsync(RiotApiTestBase.SummonersRegion, RiotApiTestBase.SummonerIds.FirstOrDefault());

Assert.IsTrue(leagues.Result.Count > 0);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueByIdAsync_Test()
@@ -118,6 +184,20 @@ public void GetLeagueByIdAsync_Test()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftLeagueByIdAsync_Test()
{
EnsureCredibility(() =>
{
// TODO: Properly implement League id test
return;
var leagues = Api.League.GetTftLeagueByIdAsync(RiotApiTestBase.SummonersRegion, "LEAGUE-ID-HERE");

Assert.IsTrue(leagues.Result.Queue != null);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueEntriesAsync_Test()
@@ -133,6 +213,20 @@ public void GetLeagueEntriesAsync_Test()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftLeagueByTierDivisionAsync_Test()
{
EnsureCredibility(() =>
{
var league = Api.League.GetTftLeagueByTierDivisionAsync(Summoner1And2Region,
Endpoints.LeagueEndpoint.Enums.Tier.Bronze,
Endpoints.LeagueEndpoint.Enums.Division.I);

Assert.IsTrue(league.Result.Count > 0);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueGrandmastersByQueueAsync_Test()
@@ -145,6 +239,17 @@ public void GetLeagueGrandmastersByQueueAsync_Test()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftGrandmasterLeagueAsync_Test()
{
EnsureCredibility(() =>
{
var league = Api.League.GetTftGrandmasterLeagueAsync(Summoner1And2Region);
Assert.IsTrue(league.Result.Entries.Count > 0);
});
}


[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
@@ -158,6 +263,18 @@ public void GetChallengerLeagueAsync_Test()
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftChallengerLeagueAsync_Test()
{
EnsureCredibility(() =>
{
var league = Api.League.GetTftChallengerLeagueAsync(Summoner1And2Region);
Assert.IsTrue(league.Result.Entries.Count > 0);
});
}


[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetMasterLeagueAsync_Test()
@@ -169,6 +286,18 @@ public void GetMasterLeagueAsync_Test()
Assert.IsTrue(league.Result.Entries.Count > 0);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTftMasterLeagueAsync_Test()
{
EnsureCredibility(() =>
{
var league = Api.League.GetTftMasterLeagueAsync(Summoner1And2Region);
Assert.IsTrue(league.Result.Entries.Count > 0);
});
}

#endregion

#region Match Tests
@@ -348,6 +477,7 @@ public void GetMatchListAsync_Index_Test()
Assert.IsTrue(matches.Count <= endIndex - beginIndex);
});
}

#endregion

#region Spectator Tests
46 changes: 46 additions & 0 deletions RiotSharp/Endpoints/Interfaces/ILeagueEndpoint.cs
Original file line number Diff line number Diff line change
@@ -60,5 +60,51 @@ public interface ILeagueEndpoint
/// <param name="rankedQueue">A ranked queue (Supported: <see cref="Misc.Queue.RankedSolo5x5"/>, <see cref="Misc.Queue.RankedFlexSR"/>, <see cref="Misc.Queue.RankedFlexTT"/>)</param>
/// <returns>A <see cref="League" /> which contains all the grandmasters for this specific region and queue.</returns>
Task<League> GetLeagueGrandmastersByQueueAsync(Region region, string rankedQueue);

/// <summary>
/// Get the TFT grandmaster league
/// </summary>
/// <param name="region">Participants server region</param>
/// <returns><see cref="LeagueEntry"> class</returns>
Task<League> GetTftGrandmasterLeagueAsync(Region region);

/// <summary>
/// Get the TFT challenger league
/// </summary>
/// <param name="region">Participants server region</param>
/// <returns><see cref="League"> class</returns>
Task<League> GetTftChallengerLeagueAsync(Region region);

/// <summary>
/// Get the TFT master league
/// </summary>
/// <param name="region">Participants server region</param>
/// <returns><see cref="League"> class</returns>
Task<League> GetTftMasterLeagueAsync(Region region);

/// <summary>
/// Gets a list of TFT league entries
/// </summary>
/// <param name="region">Summoners server region</param>
/// <param name="encryptedSummonerId">Summoners encrypted id</param>
/// <returns>List of <see cref="LeagueEntry"> class</returns>
Task<List<LeagueEntry>> GetTftLeagueEntriesBySummonerAsync(Region region, string encryptedSummonerId);

/// <summary>
/// Gets a list of league entries for a given tier/division
/// </summary>
/// <param name="region">Participants server region</param>
/// <param name="tier">Tier to get league entries from</param>
/// <param name="division">Tier division to get league entries from</param>
/// <returns>List of <see cref="LeagueEntry"> class</returns>
Task<List<LeagueEntry>> GetTftLeagueByTierDivisionAsync(Region region, LeagueEndpoint.Enums.Tier tier, LeagueEndpoint.Enums.Division division);

/// <summary>
/// Gets the TFT league by league uuid
/// </summary>
/// <param name="region">Participants server region</param>
/// <param name="leagueId">UUID of the league</param>
/// <returns><see cref="League"> object/returns>
Task<League> GetTftLeagueByIdAsync(Region region, string leagueId);
}
}
16 changes: 16 additions & 0 deletions RiotSharp/Endpoints/Interfaces/IMatchEndpoint.cs
Original file line number Diff line number Diff line change
@@ -55,5 +55,21 @@ Task<MatchList> GetMatchListAsync(Region region, string accountId,
/// <param name="region">Region in which the summoner is.</param>
/// <param name="matchId">The match ID of the timeline to be retrieved.</param>
Task<MatchTimeline> GetMatchTimelineAsync(Region region, long matchId);

/// <summary>
/// Gets a list of match ids by puuid
/// </summary>
/// <param name="region">Region in which the summoner is.</param>
/// <param name="puuid"></param>
/// <returns>A list of strings</returns>
Task<List<string>> GetTftMatchIdsByPuuidAsync(Region region, string puuid, int count = 20);

/// <summary>
/// Get a match by id
/// </summary>
/// <param name="region">Region in which the summoner is.</param>
/// <param name="matchId">The match id for the match wanting to be retrieved</param>
/// <returns><see cref="Match"> object </returns>
Task<Match> GetTftMatchByIdAsync(Region region, string matchId);
}
}
32 changes: 32 additions & 0 deletions RiotSharp/Endpoints/Interfaces/ISummonerEndpoint.cs
Original file line number Diff line number Diff line change
@@ -40,5 +40,37 @@ public interface ISummonerEndpoint
/// <param name="puuid">PUUID of the summoner you're looking for.</param>
/// <returns>A summoner.</returns>
Task<Summoner> GetSummonerByPuuidAsync(Region region, string puuid);

/// <summary>
/// Get a Teamfight Tactics summoner by account id asynchronously.
/// </summary>
/// <param name="region">Region in which you wish to look for a summoner.</param>
/// <param name="accountId">Account id of the summoner you're looking for.</param>
/// <returns>A summoner.</returns>
Task<Summoner> GetTftSummonerByAccountIdAsync(Region region, string accountId);

/// <summary>
/// Get a Teamfight Tactics summoner by name asynchronously.
/// </summary>
/// <param name="region">Region in which you wish to look for a summoner.</param>
/// <param name="summonerName">Name of the summoner you're looking for.</param>
/// <returns>A summoner.</returns>
Task<Summoner> GetTftSummonerByNameAsync(Region region, string summonerName);

/// <summary>
/// Get a Teamfight Tactics summoner by puuid asynchronously.
/// </summary>
/// <param name="region">Region in which you wish to look for a summoner.</param>
/// <param name="puuid">PUUID of the summoner you're looking for.</param>
/// <returns>A summoner.</returns>
Task<Summoner> GetTftSummonerByPuuidAsync(Region region, string summonerName);

/// <summary>
/// Get a Teamfight Tactics summoner by summoner id asynchronously.
/// </summary>
/// <param name="region">Region in which you wish to look for a summoner.</param>
/// <param name="summonerId">Id of the summoner you're looking for.</param>
/// <returns>A summoner.</returns>
Task<Summoner> GetTftSummonerBySummonerIdAsync(Region region, string summonerId);
}
}
Loading