예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
                }
            }
        }
예제 #5
0
        public void ParseIntRange_MaxRangesExceed_Exception()
        {
            var paramParser = new QueryParameterParser(2, 2);

            List <List <int> > ranges = paramParser.ParseIntRange(1, 1 + paramParser.MaxRangeLength * paramParser.MaxRanges);
        }