示例#1
0
        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)
            { }
        }
示例#2
0
        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"));
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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.");
        }
示例#6
0
        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.");
        }
示例#7
0
        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.");
        }
示例#8
0
        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.");
        }