public IEnumerable <MatchHistory> GetPages() { MatchHistory history = api.GetMatchHistory(); yield return(history); while (history.ResultsRemaining > 0) { MatchHistoryRequest request = new MatchHistoryRequest() { StartAtMatchId = history.GetLastMatchId() - 1 }; history = api.GetMatchHistory(request); yield return(history); } }
public MatchHistory GetMatchHistory(MatchHistoryRequest request) { logger.Debug("Calling GetMatchHistory with {0}", request); string url = "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=" + KEY; Uri uri = new Uri(url) .AddQuery("player_name", request.PlayerName) .AddQuery("start_at_match_id", request.StartAtMatchId) .AddQuery("date_min", request.MinDate) .AddQuery("date_max", request.MaxDate); string json = webClient.Get(uri); MatchHistoryEnvelope envelope = JsonConvert.DeserializeObject <MatchHistoryEnvelope>(json); MatchHistory history = envelope.Result; logger.Debug("Got {0} results starting at {1}; Remaining: {2}; Total:{3}", history.NumResults, history.Matches.Count == 0 ? "N/A" : history.Matches[0].Id.ToString(), history.ResultsRemaining, history.TotalResults); return(history); }
public void TestMatchPoller() { MatchHistory history = new MatchHistory(); history.Matches[5].Id = 66; mockWebAPI.Setup(webAPI => webAPI.GetMatchHistory()) .Returns(history); var poller = new MatchPoller(mockWebAPI.Object, 100); MatchSummary match = null; var matches = poller.PollMatches().GetEnumerator(); int count = 0; for (int i = 0; i < 6; i++) { matches.MoveNext(); match = matches.Current; count++; } Assert.AreEqual(66, match.Id); Assert.AreEqual(6, count); }