public void InvoiceMatcher_TwoNegativeFourPositiveValues_MatchInvoicesWithZeroTolerance() { // arrange List <double> values = new List <double>() { -82.4, -8.87, 519.09, 3568.29, 24922.98, 25993.22 }; double target = 28400.00; InvoiceMatcher invoiceMatcher = new InvoiceMatcher(values, target); // act invoiceMatcher.Match(0); // assert List <List <double> > output = new List <List <double> >() { new List <double> { -82.4, -8.87, 3568.29, 24922.98 } }; CollectionAssert.AreEqual(output, invoiceMatcher.MatchesFound); }
public void InvoiceMatcher_SingleNegativeValue_MatchInvoicesWithZeroTolerance() { // arrange List <double> values = new List <double>() { -639262.0, 1278524.0 }; double target = 639262; InvoiceMatcher invoiceMatcher = new InvoiceMatcher(values, target); // act invoiceMatcher.Match(0); // assert List <List <double> > output = new List <List <double> >() { new List <double> { -639262.0, 1278524.0 } }; CollectionAssert.AreEqual(output, invoiceMatcher.MatchesFound); }
private async Task MatchByValue(IEnumerable <Invoice> filteredInvoices, Payment payment, double difference) { InvoiceMatcher invoiceMatcher = new InvoiceMatcher(filteredInvoices.Select(_ => _.Value).ToList(), payment.Value); await Task.Run(() => { try { invoiceMatcher.Match(difference); payment.PairMatchedInvoiceValues(invoiceMatcher.MatchesFound); } catch (Exception e) { MessageBox.Show(e.Message); } }); }