예제 #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 Init()
        {
            var factory = A.Fake <IHttpClientFactory>();

            A.CallTo(() => factory.CreateClient(A <string> .Ignored))
            .WithAnyArguments()
            .Returns(client);
            stackExchange = new StackExchangeHttpClient(factory);
            service       = new ParallelQueueKeywordsSearchService(stackExchange, config2);
        }
예제 #3
0
 public void Init()
 {
     stackExchange = A.Fake <IStackExchangeHttpClient>();
     service       = new ParallelQueueKeywordsSearchService(stackExchange, config2);
 }
예제 #4
0
 public ParallelQueueKeywordsSearchService(IStackExchangeHttpClient stackExchange, IKeywordsSearchConfig config)
 {
     this.stackExchange = stackExchange;
     this.config        = config;
 }