public void ParseIntRange_1_2_Success() { var paramParser = new QueryParameterParser(2, 2); List <List <int> > ranges = paramParser.ParseIntRange(1, 2); Assert.IsNotNull(ranges); Assert.AreEqual(1, ranges.Count); Assert.AreEqual(2, ranges[0].Count); }
public void ParseIntRange_MaxRange_Success() { var paramParser = new QueryParameterParser(2, 2); List <List <int> > ranges = paramParser.ParseIntRange(1, paramParser.MaxRangeLength * paramParser.MaxRanges); Assert.IsNotNull(ranges); Assert.AreEqual(paramParser.MaxRanges, ranges.Count); foreach (var range in ranges) { Assert.AreEqual(paramParser.MaxRangeLength, range.Count); } }
public void GetInvestorsQuery_Success() { int startId = 155; // investor:true int endId = 156; // investor:false var idLists = paramParser.ParseIntRange(startId, endId); foreach (List <int> idList in idLists) { var investorsQuery = new GetInvestorsQuery(idList, new AsyncCallback(GetInvestors_Success_ProcessResult), AngelListClient, defaultLogWriter); var asyncResult = investorsQuery.BeginExecute(); asyncResult.AsyncWaitHandle.WaitOne(20 * 1000); } }
/// <summary> /// Given a range of AngelList user ids, retrieves investors and their industries from AngelList and stores them in a database. /// Range of ids is restricted by MaxRangeLength and MaxRanges. /// </summary> /// <param name="startId">AngelList user id to start the range.</param> /// <param name="endId">AngelList user id to end the range.</param> public void LoadInvestorsAndLoadUsersMarkets(int startId, int endId) { var idLists = paramParser.ParseIntRange(startId, endId); foreach (List <int> idList in idLists) { try { var investorsQuery = new GetInvestorsQuery(idList, AngelListClient, defaultLogWriter); List <User> result = (List <User>)investorsQuery.Execute(); ProcessLoadInvestorsAndLoadUsersMarkets(result); } catch (AngelListClientException ex) { var entry = new LogEntry(); entry.Categories = new string[] { "General", "Warning" }; entry.Message = string.Format("An exception occurred when calling the service. No further ids will be processed. Id list: {0}. Exception: {1}.", String.Join(",", idList), ex); entry.Severity = TraceEventType.Error; defaultLogWriter.Write(entry); } } }
public void ParseIntRange_MaxRangesExceed_Exception() { var paramParser = new QueryParameterParser(2, 2); List <List <int> > ranges = paramParser.ParseIntRange(1, 1 + paramParser.MaxRangeLength * paramParser.MaxRanges); }