public async Task <SemanticSearchCardTaskResult> ProcessUrl(string url) { var response = new SemanticSearchCardTaskResult { Url = url }; foreach (var semanticCard in _semanticSearchProducer.Producer(url)) { _logger.LogInformation("Processing semantic card '{CardName}'", semanticCard.Title); var result = await _semanticSearchConsumer.Process(semanticCard); if (result.IsSuccessful) { response.Processed += 1; } else { response.Failed.Add(result.Exception); } _logger.LogInformation("Finished processing semantic card '{CardName}'", semanticCard.Title); } response.IsSuccessful = true; return(response); }
public async Task Given_A_Valid_Url_Process_Method_Should_Be_Invoked_3_Times() { // Arrange const int expected = 3; const string url = "http://yugioh.fandom.com/index.php?title=Special%3AAsk&q=%5B%5BClass+1%3A%3AOfficial%5D%5D+%5B%5BCard+type%3A%3ANormal+Monster%5D%5D"; _semanticSearchProducer.Producer(Arg.Is(url)) .GetEnumerator() .Returns ( new List <SemanticCard> { new(), new(), new() }.GetEnumerator()