Ejemplo n.º 1
0
        public void InvalidApiInterface_RequestFails()
        {
            var response = DotaApiClient.GetHeroesAsync(apiInterface: "IDota_2_Heroes")
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestFailed(response);
            Assert.Null(response.Contents);
        }
Ejemplo n.º 2
0
        public void InvalidMethodVersion_RequestFails()
        {
            var response = DotaApiClient.GetHeroesAsync(version: "v1.2.3")
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestFailed(response);
            Assert.Null(response.Contents);
        }
Ejemplo n.º 3
0
        public void DefaultParams_ReturnsHeroes()
        {
            var response = DotaApiClient.GetHeroesAsync()
                           .Result;

            SleepAfterSendingRequest();

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

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

            // Cancel method
            source.Cancel();

            var response = await task;

            SleepAfterSendingRequest();

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