Пример #1
0
        public void GetItems_TwoWords_CheckQueueMaxSize()
        {
            var       item = new Item();
            const int operationDuraionMs = 250;

            config2 = CreateConfig(queueMaxSize2);

            stackExchange = new FakeStackExchangeHttpClient(async() => {
                await Task.Delay(operationDuraionMs);
                return(new List <Item>()
                {
                    item
                });
            });

            service = new ParallelQueueKeywordsSearchService(stackExchange, config2);
            var words = new[] { "1", "2", "3", "4", "5" };
            var timer = Stopwatch.StartNew();
            var res   = service.GetItems(words);

            timer.Stop();

            var actual = Math.Ceiling(((double)words.Length) / queueMaxSize2) * operationDuraionMs;

            Assert.IsTrue(timer.ElapsedMilliseconds >= actual);
            Assert.IsTrue(timer.ElapsedMilliseconds < words.Length * operationDuraionMs);
        }
Пример #2
0
        public void GetItems_SimpleCase_Execution()
        {
            config2 = CreateConfig(queueMaxSize2);

            service = new ParallelQueueKeywordsSearchService(FakeStackExchangeHttpClient.CreateBase(), config2);

            var words = new[] { "1", "2", "3", "4", "5" };
            var res   = service.GetItems(words);

            Assert.AreEqual(words.Length * 2, res.Count);
        }
Пример #3
0
 public ParallelQueueKeywordsSearchService(IStackExchangeHttpClient stackExchange, IKeywordsSearchConfig config)
 {
     this.stackExchange = stackExchange;
     this.config        = config;
 }