public async Task Search_ArgumentNullException_Query(string query) { var service = new WebSearchService(Enumerable.Empty <ISearchEngine>()); var ex = await Assert.ThrowsAsync <ArgumentNullException>(() => service.Search(query)); Assert.Equal(nameof(query), ex.ParamName); }
public async Task Search_EmptySearchEngineMessage_TwoEngines() { var engine = EmptySearchEngine(); var service = new WebSearchService( new List <ISearchEngine> { engine, DelaySearchEngine(3000) }); var model = await service.Search("query"); Assert.Equal(count, model.Items.Count()); Assert.Contains(WebSearchService.NotFoundMessage(engine.Name), model.Message); }
public async Task Search_EmptySearchEngineMessage_OneEngine() { var engine = EmptySearchEngine(); var service = new WebSearchService( new List <ISearchEngine> { engine }); var model = await service.Search("query"); Assert.Null(model.Items); Assert.Contains(WebSearchService.NotFoundMessage(engine.Name), model.Message); }
public async Task Search_IsFaultedMessage_OneEngine() { var engine = FaultSearchEngine(); var service = new WebSearchService( new List <ISearchEngine> { engine }); var model = await service.Search("query"); Assert.Null(model.Items); Assert.Contains(WebSearchService.IsFaultedMessage( engine.Name, exceptionMessage), model.Message); }
public async Task Search_HasOnlyFastestEngineFoundMessage_TwoEngines() { var workEngine = WorkSearchEngine(); var slowEngine = DelaySearchEngine(3000); var service = new WebSearchService( new List <ISearchEngine> { slowEngine, workEngine }); var model = await service.Search("query"); Assert.Equal(count, model.Items.Count()); Assert.Contains(WebSearchService.HasFoundMessage( workEngine.Name, count), model.Message); Assert.DoesNotContain(WebSearchService.HasFoundMessage( slowEngine.Name, count), model.Message); }