public async Task GetTextResponseModelQuery_Successful() { var textList = new List <Domain.Text>(); textList.Add(new Domain.Text("Test1")); textList.Add(new Domain.Text("Test2")); _textRepository.GetAsync(CancellationToken.None).Returns(textList); _processDataManager.ProcessDataAsync(Arg.Any <IEnumerable <Domain.Text> >()).Returns(new TextResponseModel() { VowelCount = 2 }); var handler = new GetTextResponseModelQueryHandler(_processDataManager, _textRepository); var request = new GetTextResponseModelQuery(); var result = await handler.Handle(request, CancellationToken.None); Assert.True(result.VowelCount == 2); }
public async Task <TextResponseModel> Handle(GetTextResponseModelQuery request, CancellationToken cancellationToken) { try { var texts = await _textRepository.GetAsync(cancellationToken); return(await _processDataManager.ProcessDataAsync(texts)); } catch (Exception ex) { //this can be custom exception but for simplicity for now I'm using generic exception throw ex; } }