Ejemplo n.º 1
0
        public void CountSetToZero_RequestFails()
        {
            var response = DotaApiClient.GetMatchHistoryAsync(count: 0)
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestFailed(response);
            Assert.Null(response.Contents);
        }
Ejemplo n.º 2
0
        public void InvalidApiInterface_RequestFails()
        {
            var response = DotaApiClient.GetMatchHistoryAsync(apiInterface: "IDota_2_History")
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestFailed(response);
            Assert.Null(response.Contents);
        }
Ejemplo n.º 3
0
        public void InvalidMethodVersion_RequestFails()
        {
            var response = DotaApiClient.GetMatchHistoryAsync(version: "v123")
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestFailed(response);
            Assert.Null(response.Contents);
        }
Ejemplo n.º 4
0
        public void CountParamDefined_ReturnsSpecifiedAmount(uint count, uint resultCount)
        {
            var response = DotaApiClient.GetMatchHistoryAsync(count: count)
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.True(response.Contents.Count == resultCount);
        }
Ejemplo n.º 5
0
        public void MinPlayersSpecified_ReturnsMatchesWithMinimumPLayerCount(uint minPlayerCount)
        {
            var response = DotaApiClient.GetMatchHistoryAsync(minPlayers: minPlayerCount)
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.All(response.Contents, match => {
                Assert.True(match.Players.Count >= minPlayerCount);
            });
        }
Ejemplo n.º 6
0
        public void AccountIdSpecified_ReturnsMatchesWithSpecifiedAccount(uint playerId)
        {
            var response = DotaApiClient.GetMatchHistoryAsync(id32: playerId, count: 5)
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.All(response.Contents, match => {
                Assert.Contains(match.Players, (player) => player.Id32 == playerId);
            });
        }
Ejemplo n.º 7
0
        public void SkillLevelSpecified_ReturnsOnlyGamesWithSpecifiedSkill(DotaSkillLevel skillLvl)
        {
            var response = DotaApiClient.GetMatchHistoryAsync(skillLevel: skillLvl)
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.All(response.Contents, match =>
            {
                Assert.Equal(match.SkillLevel, (int)skillLvl);
            });
        }
Ejemplo n.º 8
0
        [InlineData(9870)]  // The International 2018
        public void LeagueIdSpecified_ReturnsMatchesFromSpecifiedLeague(uint leagueId)
        {
            var response = DotaApiClient.GetMatchHistoryAsync(leagueId: leagueId)
                           .Result;

            SleepAfterSendingRequest();
            var detailsResponse = DotaApiClient.GetMatchDetailsAsync(
                response.Contents.ElementAt(0).Id).Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.Equal(leagueId, detailsResponse.Contents.LeagueId);
        }
Ejemplo n.º 9
0
        public void HeroSpecified_ReturnsOnlyGamesWithSpecifiedHero(uint heroId)
        {
            var response = DotaApiClient.GetMatchHistoryAsync(heroId: heroId, count: 2)
                           .Result;

            SleepAfterSendingRequest();

            AssertRequestWasSuccessful(response);
            Assert.NotNull(response.Contents);
            Assert.All(response.Contents, match =>
            {
                var players = from p in match.Players
                              where p.HeroId == heroId
                              select p;
                Assert.Contains(players, (player) => player.HeroId == heroId);
            });
        }
Ejemplo n.º 10
0
        public async Task MethodGotCancelled_RequestFails()
        {
            CancellationTokenSource source = new CancellationTokenSource();

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

            // Cancel method
            source.Cancel();
            var response = await task;

            SleepAfterSendingRequest();

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