public async Task RateLimitTest_ShouldThrottleSpecificMethod() { IRiotClient client = new RiotClient(new RateLimiter()); client.Settings.RetryOnRateLimitExceeded = true; client.RateLimitExceeded += (o, e) => { if (e.Response != null) { Assert.Fail("Rate limit was exceeded! Proactive rate limiting failed."); } }; for (var i = 0; i < 10; ++i) { var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); var champs = await client.GetStaticChampionsAsync(token : cts.Token); Assert.That(champs, Is.Not.Null, "Failed to get champion: " + i); } try { var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); await client.GetStaticChampionsAsync(token : cts.Token); Assert.Fail("Successfully hit the static data endpoint 11 times! This test probably needs to be updated."); } catch (OperationCanceledException) { } }
public async Task GetStaticChampionsAsyncTest_WithLocale() { IRiotClient client = new RiotClient(); var championList = await client.GetStaticChampionsAsync(Locale.de_DE); Assert.That(championList.Data.Count, Is.GreaterThan(0)); var champion = championList.Data["Jax"]; Assert.That(champion.Title, Is.EqualTo("Der Großmeister der Waffen")); }
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 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 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 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(); int id; var isInteger = int.TryParse(key, out id); Assert.That(isInteger, Is.True, "Champs are listed by key, but should be listed by ID."); }
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 GetStaticChampionsAsyncTest() { IRiotClient client = new RiotClient(); var championList = await client.GetStaticChampionsAsync(champListData: new[] { "all" }); Assert.That(championList.Data.Count, Is.GreaterThan(0)); Assert.That(championList.Format, Is.Not.Null.And.Not.Empty); Assert.That(championList.Keys.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 NOT be an integer var key = championList.Data.Keys.First(); int id; var isInteger = int.TryParse(key, out id); Assert.That(isInteger, Is.False, "Champs are listed by ID, but should be listed by key."); }