public async Task ReturnExpectedTotalAmount() { var totalAmount = await _sut.CalculateTotalAmount(_invoice.Items); _output.WriteLine($"Expected total amount value is {_invoice.TotalAmount}"); _output.WriteLine($"Calculated total amount value is {totalAmount}"); Assert.Equal(_invoice.TotalAmount, totalAmount, 4); }
public async Task <InvoiceInsertResponse> InsertOneAsync(AddInvoiceModel invoiceModel) { var invoiceValidator = new InvoiceValidator(_currencyRepository); var response = await invoiceValidator.ValidateInvoiceCurrencies(invoiceModel); if (response.ValidationResult.Status == ValidationStatus.Error) { return(await Task.FromResult(response)); } var invoice = _mapper.Map <Invoice>(invoiceModel); invoice.Number = await GenerateInvoiceNumberAsync(); invoice.TotalAmount = await _calculator.CalculateTotalAmount(invoice.Items); await _invoiceRepository.InsertOneAsync(invoice); response.InvoiceNumber = invoice.Number; return(await Task.FromResult(response)); }