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); }
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); }
public void Init() { stackExchange = A.Fake <IStackExchangeHttpClient>(); service = new ParallelQueueKeywordsSearchService(stackExchange, config2); }
public ParallelQueueKeywordsSearchService(IStackExchangeHttpClient stackExchange, IKeywordsSearchConfig config) { this.stackExchange = stackExchange; this.config = config; }