public void InvalidMethodVersion_RequestFails()
        {
            var response = DotaApiClient.GetCosmeticRaritiesAsync(version: "v1.2.3")
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestFailed(response);
            Assert.Null(response.Contents);
        }
        public void InvalidApiInterface_RequestFails()
        {
            var response = DotaApiClient.GetCosmeticRaritiesAsync(apiInterface: "IDota_2_Heroe")
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestFailed(response);
            Assert.Null(response.Contents);
        }
        public void GetCosmeticRaritiesAsync_LanguageProvided_ReturnsLocalizedRarities(string lang,
                                                                                       string[] locNames)
        {
            var response = DotaApiClient.GetCosmeticRaritiesAsync(lang: lang)
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.NotEmpty(response.Contents);
            Assert.All(response.Contents, rarity =>
            {
                Assert.Contains(locNames, r => r == rarity.LocalizedName);
            });
        }
        public void GetCosmeticRaritiesAsync_DefaultParams_ReturnsRarities()
        {
            var response = DotaApiClient.GetCosmeticRaritiesAsync()
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.NotEmpty(response.Contents);
            Assert.All(response.Contents, rarity =>
            {
                Assert.NotEmpty(rarity.LocalizedName);
                Assert.NotEmpty(rarity.Name);
                Assert.NotEmpty(rarity.Color);
                Assert.NotEqual((uint)0, rarity.Id);
            });
        }
        public async Task MethodGotCancelled_RequestFails()
        {
            CancellationTokenSource source = new CancellationTokenSource();

            // Start task to be cancelled
            var task = Task.Run(async() =>
            {
                return(await DotaApiClient.GetCosmeticRaritiesAsync(cToken: source.Token));
            });

            // Cancel method
            source.Cancel();

            var response = await task;

            SleepAfterSendingRequest();

            AssertRequestWasCancelled(response);
            Assert.Null(response.Contents);
        }