public async Task Given_A_Category_And_A_SemanticCard_Should_Execute_Process() { // Arrange var category = "Flip"; var semanticCard = new SemanticCard { Name = "Red-Eyes Black Dragon" }; _semanticCardProcessor.Process(Arg.Any <string>(), Arg.Any <SemanticCard>()).Returns(new SemanticSearchTaskResult()); // Act await _sut.Process(category, semanticCard); // Assert await _semanticCardProcessor.Received(1).Process(Arg.Any <string>(), Arg.Any <SemanticCard>()); }
public async Task <SemanticSearchBatchTaskResult> Process(string category, SemanticCard[] semanticCards) { if (string.IsNullOrWhiteSpace(category)) { throw new ArgumentException(nameof(category)); } if (semanticCards == null) { throw new ArgumentException(nameof(semanticCards)); } var response = new SemanticSearchBatchTaskResult(); foreach (var semanticCard in semanticCards) { try { var result = await _semanticCardProcessor.Process(category, semanticCard); if (result.IsSuccessfullyProcessed) { response.Processed += 1; } } catch (Exception ex) { _logger.Error("{1} | ' {0} '", semanticCard.Name, category); _logger.Error(ex); response.Failed.Add(new SemanticSearchException { Card = semanticCard, Exception = ex }); } } return(response); }
public Task <SemanticSearchTaskResult> Process(string category, SemanticCard semanticCard) { _logger.Info("{1} | ' {0} '", semanticCard.Name, category); return(_semanticCardProcessor.Process(category, semanticCard)); }