public async Task <string> Handle(CalculateInterestCommand request, CancellationToken cancellationToken) { var interest = await _interestTaxClienthttp.GetInterestTaxAsync(); if (string.IsNullOrWhiteSpace(interest)) { _notification.RaiseError("Não foi possível obter a taxa de juros."); return(default);
public async Task Should_Calculate_Interest(double initialValue, int months, string expectedResult) { _http.GetInterestTaxAsync().ReturnsForAnyArgs(x => { return(Task.FromResult("0.01")); }); var calculateInterestCommand = new CalculateInterestCommand(initialValue, months); var result = await new CalculateInterestHandler(_http, _notification, _configuration).Handle(calculateInterestCommand, new CancellationToken()); Assert.True(result == expectedResult); Assert.True(!_notification.HasNotifications()); }