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

LoR and TFT update #648

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions RiotSharp.AspNetCore/IServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public static IServiceCollection AddRiotSharp(this IServiceCollection serviceCol
serviceCollection.AddSingleton<IStaticDataEndpoints>(serviceProvider =>
new StaticDataEndpoints(serviceProvider.GetRequiredService<IStaticEndpointProvider>()));

serviceCollection.AddSingleton<IRiotApi>(serviceProvider =>
new RiotApi(rateLimitedRequester, serviceProvider.GetRequiredService<IStaticEndpointProvider>()));
//serviceCollection.AddSingleton<IRiotApi>(serviceProvider =>
//new RiotApi(rateLimitedRequester, serviceProvider.GetRequiredService<IStaticEndpointProvider>()));
}

if (riotSharpOptions.TournamentApi.ApiKey != null)
Expand Down
2 changes: 1 addition & 1 deletion RiotSharp.AspNetCore/RiotSharp.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<PackageId>RiotSharp.AspNetCore</PackageId>
<Version>0.1.0</Version>
<PackageVersion>0.1.0</PackageVersion>
Expand Down
10 changes: 5 additions & 5 deletions RiotSharp.Test/CommonTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class CommonTestBase
public static string ApiKey = Configuration["ApiKey"];
public static string FaultyApiKey = "deadbeef-dead-beef-dead-beefdeadbeef";

public static Region Summoner1And2Region = (Region)Enum.Parse(typeof(Region), "Na");
public static Region Summoner1And2Region = (Region)Enum.Parse(typeof(Region), "Eun1");

public static long InvalidSummonerId = -1;
public static string Summoner1Id = "fhOx2QJ2VKSaaD9nVJ4XJSzMBPW2es7FboigIwW5ss97coA";
public static string Summoner1AccountId = "6GwG-_gvthMjC4bMSh-K_n89fXmwAO2r_xW_bydQX6jsQdI";
public static string Summoner1Name = "toothlessG";
public static string Summoner1Puuid = "R2RjsXCUB-zJ9T5cZVr1ZI4vVqa3sOR61xRmU71bsJ3o_TCRR_ttdVphhKaD4y57xcvB2AdrNWqGKw";
public static string Summoner1Id = "79Ks2KwGjbX3ar0InA4SZoo5VhBffkYmvjHIFfCNzWqtiZM";
public static string Summoner1AccountId = "IjeB_hkeO8eS9-g36yTJvXPuHu7ge6rLRhYkIfJSVVLiqQ";
public static string Summoner1Name = "Feeding King";
public static string Summoner1Puuid = "NrPw06OU-eP-iQEh-V1oXcA3IeIA9ofQf5e-1dgt7uY5TT_FFDTaGQgiDKNaDqat8IXTpRTUuj5mIA";

public static long Summoner2Id = 31815991;
public static long Summoner2AccountId = 46532395;
Expand Down
34 changes: 34 additions & 0 deletions RiotSharp.Test/EndpointTests/ChampionEndpointTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using RiotSharp.Caching;
using RiotSharp.Endpoints.ChampionEndpoint;
using RiotSharp.Endpoints.Interfaces;
using RiotSharp.Http.Interfaces;
using RiotSharp.Misc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace RiotSharp.Test.EndpointTests
{
[TestClass]
public class ChampionEndpointTests : CommonTestBase
{
private static readonly RiotApi Api = RiotApi.GetDevelopmentInstance(ApiKey);

[TestMethod]
[TestCategory("ChampionRotation"), TestCategory("Async")]
public void GetChampionRotationAsync_Test()
{
EnsureCredibility(() =>
{
var championRotation = Api.Champion.GetChampionRotationAsync(Region.Eun1).Result;

Assert.IsTrue(championRotation.FreeChampionIds.Count == 15);
Assert.IsTrue(championRotation.FreeChampionIdsForNewPlayers.Count == 10);
Assert.IsTrue(championRotation.MaxNewPlayerLevel > 0);
});
}
}
}
56 changes: 56 additions & 0 deletions RiotSharp.Test/EndpointTests/ChampionMasteryEndpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;

namespace RiotSharp.Test.EndpointTests
{
[TestClass]
public class ChampionMasteryEndpoint : CommonTestBase
{
private static readonly RiotApi Api = RiotApi.GetDevelopmentInstance(ApiKey);

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetChampionMasteryAsync_Test()
{
EnsureCredibility(() =>
{
var championMastery = Api.ChampionMastery.GetChampionMasteryAsync(Summoner1And2Region,
Summoner1Id, RiotApiTestBase.Summoner1MasteryChampionId).Result;

Assert.AreEqual(RiotApiTestBase.Summoner1MasteryChampionId,
championMastery.ChampionId);
Assert.AreEqual(RiotApiTestBase.Summoner1MasteryChampionLevel,
championMastery.ChampionLevel);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetChampionsMasteriesAsync_Test()
{
EnsureCredibility(() =>
{
var allChampionsMastery = Api.ChampionMastery.GetChampionMasteriesAsync(
Summoner1And2Region, Summoner1Id).Result;

Assert.IsNotNull(allChampionsMastery.Find(championMastery =>
championMastery.ChampionId == RiotApiTestBase.Summoner1MasteryChampionId));
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetTotalChampionMasteryScoreAsync_Test()
{
EnsureCredibility(() =>
{
var totalChampionMasteryScore = Api.ChampionMastery.GetTotalChampionMasteryScoreAsync(
Summoner1And2Region, Summoner1Id).Result;

Assert.IsTrue(totalChampionMasteryScore > -1);
});
}
}
}
92 changes: 92 additions & 0 deletions RiotSharp.Test/EndpointTests/LeagueEndpointTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RiotSharp.Misc;
using System;
using System.Collections.Generic;
using System.Text;

namespace RiotSharp.Test.EndpointTests
{
[TestClass]
public class LeagueEndpointTest : CommonTestBase
{
private static readonly RiotApi Api = RiotApi.GetDevelopmentInstance(ApiKey);

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueEntriesBySummonerAsync_Test()
{
EnsureCredibility(() =>
{
// TODO: tests for other sumoners
var leagues = Api.League.GetLeagueEntriesBySummonerAsync(RiotApiTestBase.SummonersRegion, RiotApiTestBase.SummonerIds[0]);

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

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueByIdAsync_Test()
{
EnsureCredibility(() =>
{
var leagues = Api.League.GetLeagueByIdAsync(RiotApiTestBase.SummonersRegion, "5ae26d6d-c07a-3d29-ae0f-1ac9ca4a4f4a");

Assert.IsTrue(leagues.Result.Queue != null);
Assert.AreEqual(Tier.Challenger, leagues.Result.Tier);
});
}

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueEntriesAsync_Test()
{
EnsureCredibility(() =>
{
var leagues = Api.League.GetLeagueEntriesAsync(RiotApiTestBase.SummonersRegion,
RiotSharp.Misc.Queue.RankedSolo5x5,
Tier.Bronze,
Division.I);

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

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetLeagueGrandmastersByQueueAsync_Test()
{
EnsureCredibility(() =>
{
var leagues = Api.League.GetLeagueGrandmastersByQueueAsync(RiotApiTestBase.SummonersRegion, RiotSharp.Misc.Queue.RankedSolo5x5);

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


[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetChallengerLeagueAsync_Test()
{
EnsureCredibility(() =>
{
var league = Api.League.GetChallengerLeagueAsync(Summoner1And2Region, RiotApiTestBase.Queue);

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

[TestMethod]
[TestCategory("RiotApi"), TestCategory("Async")]
public void GetMasterLeagueAsync_Test()
{
EnsureCredibility(() =>
{
var league = Api.League.GetMasterLeagueAsync(Summoner1And2Region, RiotApiTestBase.Queue);

Assert.IsTrue(league.Result.Entries.Count > 0);
});
}
}
}
27 changes: 27 additions & 0 deletions RiotSharp.Test/EndpointTests/LoRTests/LoRRankedEndpointTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RiotSharp.Misc;
using System;
using System.Collections.Generic;
using System.Text;

namespace RiotSharp.Test.EndpointTests.LoRTests
{
[TestClass]
public class LoRRankedEndpointTests : CommonTestBase
{
private static readonly RiotApi Api = RiotApi.GetDevelopmentInstance(ApiKey);

[TestMethod]
[TestCategory("LoR"), TestCategory("Async")]
public void GetLoRRankedLeaderboardsAsync_Test()
{
EnsureCredibility(() =>
{
var leaderboards = Api.LoR_Leaderboards.GetLoRRankedLeaderboardsAsync(Region.Europe).Result;

Assert.IsTrue(leaderboards.Players.Count == 6);
Assert.AreEqual(0, leaderboards.Players[0].Rank);
});
}
}
}
Loading