Esempio n. 1
0
        public static void Main(string[] args)
        {
            //Create new instance of DotaCore object using API key
            DotaCore lib = new DotaCore(ApiKey);

            //DotaCore.GetMatchHistory fetches match history of a specific accountid
            MatchHistoryResult matchHistory = lib.GetMatchHistory(accountId: 32588391, matchesRequested: 1);

            Debug.Assert(matchHistory != null);
            Debug.Assert(matchHistory.Matches.Count == 1);

            //DotaCore.GetMatchDetails gets detailed information about a specific matchid
            MatchDetailsResult matchDetails1 = lib.GetMatchDetails(3053641442); // Recent tournament match
            MatchDetailsResult matchDetails2 = lib.GetMatchDetails(501672851);  // Old wraith night game

            Debug.Assert(matchDetails1 != null);
            Debug.Assert(matchDetails1.RadiantWin == true);
            Debug.Assert(matchDetails2 != null);
            Debug.Assert(matchDetails2.RadiantWin == false);

            //DotaCore.GetHeroDetails fetches all heroes in the API with hero names localized to en_uk (en_us default)
            HeroDetailsResult heroDetails = lib.GetAllHeroDetails("en_uk");

            Debug.Assert(heroDetails.Status == (int)HttpStatusCode.OK);

            //DotaCore.GetItemDetails fetches all items in the API with item names localized to en_uk (en_us default)
            ItemDetailsResult itemDetails = lib.GetAllItemDetails("en_uk");

            Debug.Assert(itemDetails.Status == (int)HttpStatusCode.OK);

            Console.WriteLine("All POC tests have passed. Press any key to continue");
            Console.ReadKey();
        }
Esempio n. 2
0
 public static Match MapMatch(MatchHistoryMatch matchHistory, MatchDetailsResult matchDetails)
 {
     return(new Match()
     {
         BarracksStatusDire = matchDetails.BarracksStatusDire,
         BarracksStatusRadiant = matchDetails.BarracksStatusRadiant,
         Cluster = matchDetails.Cluster,
         DireScore = matchDetails.DireScore,
         DireTeamId = matchHistory.DireTeamId,
         Duration = matchDetails.Duration,
         Engine = matchDetails.Engine,
         FirstBloodTime = matchDetails.FirstBloodTime,
         Flags = matchDetails.Flags,
         GameMode = matchDetails.GameMode,
         HumanPlayers = matchDetails.HumanPlayers,
         LeagueId = matchDetails.LeagueId,
         LobbyType = matchDetails.LobbyType,
         MatchId = matchDetails.MatchId,
         MatchSeqNum = matchDetails.MatchSeqNum,
         NegativeVotes = matchDetails.NegativeVotes,
         Players = MapPlayers(matchDetails.Players),
         PositiveVotes = matchDetails.PositiveVotes,
         PreGameDuration = matchDetails.PreGameDuration,
         RadiantScore = matchDetails.RadiantScore,
         RadiantTeamId = matchHistory.RadiantTeamId,
         RadiantWin = matchDetails.RadiantWin,
         StartTime = matchDetails.StartTime,
         TowerStatusDire = matchDetails.TowerStatusDire,
         TowerStatusRadiant = matchDetails.TowerStatusRadiant
     });
 }
        public void GetMatchDetails_FailedFetch()
        {
            _httpClientMock.Setup(s => s.SendRequest(It.IsAny <string>())).Returns(MatchDetailsServiceMockData.FailedMatch);
            IMatchDetailsService service = new MatchDetailsService(_httpClientMock.Object, MockApiKey);
            MatchDetailsResult   result  = service.GetMatchDetails(MockMatchId).Result;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.ErrorMessage);
        }
        public void GetMatchDetails_NewMatch()
        {
            _httpClientMock.Setup(s => s.SendRequest(It.IsAny <string>())).Returns(MatchDetailsServiceMockData.NewMatch);
            IMatchDetailsService service = new MatchDetailsService(_httpClientMock.Object, MockApiKey);
            MatchDetailsResult   result  = service.GetMatchDetails(MockMatchId).Result;

            Assert.AreEqual(result.MatchDuration, 2151);
            Assert.IsFalse(result.RadiantWin);
            Assert.IsNull(result.ErrorMessage);
        }
Esempio n. 5
0
        public async Task Upsert(MatchHistoryMatch match, MatchDetailsResult matchDetails)
        {
            var existingMatch = Get(match.MatchId);

            if (existingMatch == null)
            {
                var mappedMatch = Mapper.MapMatch(match, matchDetails);

                mappedMatch.Id           = Guid.NewGuid();
                mappedMatch.LastModified = DateTime.UtcNow;

                await Context.Repositories.Matches.Upsert(mappedMatch);
            }
        }