Skip to content

Commit

Permalink
Move the match API to V3, closes BenFradet#433 (BenFradet#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shidesu authored and BenFradet committed Nov 4, 2017
1 parent d1c28d3 commit 3b42dbc
Show file tree
Hide file tree
Showing 19 changed files with 454 additions and 391 deletions.
4 changes: 2 additions & 2 deletions RiotSharp.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ static void Main(string[] args)

var match1 = api.GetMatch(region, gameId);

Console.WriteLine(match1.MapType);
Console.WriteLine(match1.MapId);

var shardStatus = statusApi.GetShardStatus(region);

var games = api.GetRecentGames(region, id);
var games = api.GetRecentMatches(region, id);

Console.WriteLine("Done! Press Enter to exit.");
Console.ReadLine();
Expand Down
117 changes: 55 additions & 62 deletions RiotSharp.Test/RiotApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,70 +415,73 @@ public void GetMasterLeagueAsync_Test()
#endregion

#region Match Tests
[Ignore]
[TestMethod]
[TestCategory("RiotApi")]
public void GetMatch_WithoutTimeline_Test()
public void GetMatch_WithoutAccountId_Test()
{
EnsureCredibility(() =>
{
var game = Api.GetMatch(Summoner1And2Region, RiotApiTestBase.GameId);
var match = api.GetMatch(RiotApiTestBase.summoner1and2Region, RiotApiTestBase.gameId);

Assert.AreEqual(RiotApiTestBase.GameId, game.MatchId);
Assert.IsNull(game.Timeline);
Assert.AreEqual(RiotApiTestBase.gameId, match.GameId);
Assert.IsNotNull(match.ParticipantIdentities);
Assert.IsNotNull(match.Participants);
Assert.IsNotNull(match.Teams);
});
}

[TestMethod]
[TestCategory("RiotApi")]
public void GetMatch_WithTimeline_Test()
public void GetMatch_WithAccountId_Test()
{
EnsureCredibility(() =>
{
var game = Api.GetMatch(Summoner1And2Region, RiotApiTestBase.GameId, true);
var match = api.GetMatch(RiotApiTestBase.summoner1and2Region, RiotApiTestBase.gameId, RiotApiTestBase.summoner1AccountId);

Assert.AreEqual(RiotApiTestBase.GameId, game.MatchId);
Assert.IsNotNull(game.Timeline);
Assert.AreEqual(RiotApiTestBase.gameId, match.GameId);
Assert.IsNotNull(match.ParticipantIdentities);
Assert.IsNotNull(match.Participants);
Assert.IsNotNull(match.Teams);
});
}

[Ignore]
[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetMatchAsync_WithoutTimeline_Test()
public void GetMatchAsync_WithoutAccountId_Test()
{
EnsureCredibility(() =>
{
var game = Api.GetMatchAsync(Summoner1And2Region, RiotApiTestBase.GameId);
var match = api.GetMatchAsync(RiotApiTestBase.summoner1and2Region, RiotApiTestBase.gameId).Result;

Assert.AreEqual(RiotApiTestBase.GameId, game.Result.MatchId);
Assert.IsNull(game.Result.Timeline);
Assert.AreEqual(RiotApiTestBase.gameId, match.GameId);
Assert.IsNotNull(match.ParticipantIdentities);
Assert.IsNotNull(match.Participants);
Assert.IsNotNull(match.Teams);
});
}

[Ignore]
[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetMatchAsync_WithTimeline_Test()
public void GetMatchAsync_WithAccountId_Test()
{
EnsureCredibility(() =>
{
var game = Api.GetMatchAsync(Summoner1And2Region, RiotApiTestBase.GameId, true);
var match = api.GetMatchAsync(RiotApiTestBase.summoner1and2Region, RiotApiTestBase.gameId, RiotApiExceptionTestBase.summoner1AccountId).Result;

Assert.AreEqual(RiotApiTestBase.GameId, game.Result.MatchId);
Assert.IsNotNull(game.Result.Timeline);
Assert.AreEqual(RiotApiTestBase.gameId, match.GameId);
Assert.IsNotNull(match.ParticipantIdentities);
Assert.IsNotNull(match.Participants);
Assert.IsNotNull(match.Teams);
});
}

[Ignore]
[TestMethod]
[TestCategory("RiotApi")]
public void GetMatchList_Test()
public void GetMatchList_NoFiltering_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchList(Summoner1And2Region,
Summoner1Id).Matches;
var matches = api.GetMatchList(RiotApiTestBase.summoner1and2Region, RiotApiTestBase.summoner1AccountId).Matches;

Assert.IsTrue(matches.Any());
});
Expand All @@ -491,8 +494,8 @@ public void GetMatchList_ChampionIds_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchList(Summoner1And2Region,
Summoner1Id, new List<long> { RiotApiTestBase.ChampionId }).Matches;
var matches = api.GetMatchList(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, new List<int> { RiotApiTestBase.championId }).Matches;

Assert.IsTrue(matches.Any());
foreach (var match in matches)
Expand All @@ -510,10 +513,8 @@ public void GetMatchList_RankedQueues_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchList(Summoner1And2Region,
Summoner1Id, null, new List<string> { RiotApiTestBase.Queue }).Matches;

Assert.IsTrue(matches.Any());
var matches = api.GetMatchList(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null, new List<int> { RiotApiTestBase.queueId }).Matches;

foreach (var match in matches)
{
Expand All @@ -529,10 +530,8 @@ public void GetMatchList_Seasons_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchList(Summoner1And2Region,
Summoner1Id, null, null, new List<Season> { RiotApiTestBase.season }).Matches;

Assert.IsTrue(matches.Any());
var matches = api.GetMatchList(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null, null, new List<Season> { RiotApiTestBase.season }).Matches;

foreach (var match in matches)
{
Expand All @@ -548,8 +547,8 @@ public void GetMatchList_DateTimes_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchList(Summoner1And2Region,
Summoner1Id, null, null, null, BeginTime, EndTime).Matches;
var matches = api.GetMatchList(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null, null, null, beginTime, endTime).Matches;

Assert.IsTrue(matches.Any());
foreach (var match in matches)
Expand All @@ -569,9 +568,9 @@ public void GetMatchList_Index_Test()
{
const int beginIndex = 0;
const int endIndex = 32;

var matches = Api.GetMatchList(Summoner1And2Region,
Summoner1Id, null, null, null, null, null, beginIndex, endIndex).Matches;
var matches = api.GetMatchList(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null, null, null, null, null, beginIndex, endIndex).Matches;

Assert.IsTrue(matches.Count <= endIndex - beginIndex);
});
Expand All @@ -584,8 +583,8 @@ public void GetMatchListAsync_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchListAsync(Summoner1And2Region,
Summoner1Id).Result.Matches;
var matches = api.GetMatchListAsync(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId).Result.Matches;

Assert.IsTrue(matches.Any());
});
Expand All @@ -598,10 +597,8 @@ public void GetMatchListAsync_ChampionIds_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchListAsync(Summoner1And2Region,
Summoner1Id, new List<long> { RiotApiTestBase.ChampionId }).Result.Matches;

Assert.IsTrue(matches.Any());
var matches = api.GetMatchListAsync(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, new List<int> { RiotApiTestBase.championId }).Result.Matches;

foreach (var match in matches)
{
Expand All @@ -614,15 +611,13 @@ public void GetMatchListAsync_ChampionIds_Test()
[Ignore]
[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetMatchListAsync_RankedQueues_Test()
public void GetMatchListAsync_Queues_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchListAsync(Summoner1And2Region,
Summoner1Id, null,
new List<string> { RiotApiTestBase.Queue }).Result.Matches;

Assert.IsTrue(matches.Any());
var matches = api.GetMatchListAsync(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null,
new List<int> { RiotApiTestBase.queueId }).Result.Matches;

foreach (var match in matches)
{
Expand All @@ -638,8 +633,8 @@ public void GetMatchListAsync_Seasons_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchListAsync(Summoner1And2Region,
Summoner1Id, null, null,
var matches = api.GetMatchListAsync(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null, null,
new List<Season> { RiotApiTestBase.season }).Result.Matches;

Assert.IsTrue(matches.Any());
Expand All @@ -658,10 +653,8 @@ public void GetMatchListAsync_DateTimes_Test()
{
EnsureCredibility(() =>
{
var matches = Api.GetMatchListAsync(Summoner1And2Region,
Summoner1Id, null, null, null, BeginTime, EndTime).Result.Matches;

Assert.IsTrue(matches.Any());
var matches = api.GetMatchListAsync(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null, null, null, beginTime, endTime).Result.Matches;

foreach (var match in matches)
{
Expand All @@ -681,8 +674,8 @@ public void GetMatchListAsync_Index_Test()
const int beginIndex = 0;
const int endIndex = 32;

var matches = Api.GetMatchListAsync(Summoner1And2Region,
Summoner1Id, null, null, null, null, null, beginIndex, endIndex).Result.Matches;
var matches = api.GetMatchListAsync(RiotApiTestBase.summoner1and2Region,
RiotApiTestBase.summoner1AccountId, null, null, null, null, null, beginIndex, endIndex).Result.Matches;

Assert.IsTrue(matches.Count <= endIndex - beginIndex);
});
Expand All @@ -692,23 +685,23 @@ public void GetMatchListAsync_Index_Test()
#region Spectator Tests
[TestMethod]
[TestCategory("RiotApi")]
public void GetRecentGames_Test()
public void GetRecentMatches_Test()
{
EnsureCredibility(() =>
{
var games = Api.GetRecentGames(Summoner1And2Region, Summoner1Id);
var games = api.GetRecentMatches(RiotApiTestBase.summoner1and2Region, RiotApiTestBase.summoner1AccountId);

Assert.IsTrue(games.Count > 0);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetRecentGamesAsync_Test()
public void GetRecentMatchesAsync_Test()
{
EnsureCredibility(() =>
{
var games = Api.GetRecentGamesAsync(Summoner1And2Region, Summoner1Id);
var games = api.GetRecentMatchesAsync(RiotApiTestBase.summoner1and2Region, RiotApiTestBase.summoner1AccountId);

Assert.IsTrue(games.Result.Any());
});
Expand Down
11 changes: 8 additions & 3 deletions RiotSharp.Test/RiotApiTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ class RiotApiTestBase : CommonTestBase
55629820, 32932398, 56539172 };
public static List<string> SummonerNames = new List<string> { "Imaqtpie", "C9 Ray", "C9 Gun", "C9 Winter", "Fox Brandini", "P1 Shady",
"clg imaqtpie69", "Anivia Kid", "Butler Delta", "Contractz", "LL Stylish" };
public static Region SummonersRegion = (Region)Enum.Parse(typeof(Region), "na");
public static string Queue = "RANKED_SOLO_5x5";
public static Season season = (Season)Enum.Parse(typeof(Season), "Season2015");
public static Region summonersRegion = (Region)Enum.Parse(typeof(Region), "na");
public static string queue = "RANKED_SOLO_5x5";
/// <summary>
/// Normal 5v5 Draft Pick games
/// </summary>
public static int queueId = 14;
public static RiotSharp.MatchEndpoint.Enums.Season season =
(RiotSharp.MatchEndpoint.Enums.Season)Enum.Parse(typeof(RiotSharp.MatchEndpoint.Enums.Season), "Season2015");
}
}
Loading

0 comments on commit 3b42dbc

Please sign in to comment.