public void Will_detect_that_permutations_are_not_duplicates_when_transactions_have_identical_amounts_and_descriptions_but_different_dates() { // Arrange var amount_to_match = 20.00; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Unreconciled_amount = 10.00, Description = "Match01", Date = DateTime.Today.AddDays(1) }, new CredCard2InOutRecord { Unreconciled_amount = 10.00, Description = "Match01", Date = DateTime.Today.AddDays(2) }, new CredCard2InOutRecord { Unreconciled_amount = 10.00, Description = "Match01", Date = DateTime.Today.AddDays(3) } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.AreEqual(3, result.Count); Assert.AreEqual(2, result.Count(x => x.Actual_records.Any(y => y.Date == DateTime.Today.AddDays(1)))); Assert.AreEqual(2, result.Count(x => x.Actual_records.Any(y => y.Date == DateTime.Today.AddDays(2)))); Assert.AreEqual(2, result.Count(x => x.Actual_records.Any(y => y.Date == DateTime.Today.AddDays(3)))); }
private void Match_records(CredCard2Record source, ICSVRecord match) { match.Matched = true; source.Matched = true; match.Match = source; source.Match = match; }
public void Will_not_return_transactions_that_have_already_been_matched() { // Arrange var amount_to_match = 10.00; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = amount_to_match, Description = "Not matched", Matched = false }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = amount_to_match, Description = "Matched", Matched = true } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.AreEqual(1, result.Count); Assert.IsFalse(result.Any(x => x.Actual_records.Any(y => y.Matched))); }
public void Will_populate_console_lines_for_every_potential_match() { // Arrange var amount_to_match = 10.00; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Unreconciled_amount = amount_to_match, Date = DateTime.Today } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.NotNull(result[0].Console_lines); }
public void Will_match_on_a_single_identical_amount() { // Arrange var amount_to_match = 10.00; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Unreconciled_amount = amount_to_match, Date = DateTime.Today } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.AreEqual(1, result.Count); Assert.AreEqual(candidate_rows[0], result[0].Actual_records[0]); }
public void When_copying_record_will_create_new_object() { // Arrange var original_date = DateTime.Today; var original_amount = 12.34; var original_description = "Description"; var cred_card2_record = new CredCard2Record { Date = original_date, Amount = original_amount, Description = original_description, }; cred_card2_record.Update_source_line_for_output(','); var original_source_line = cred_card2_record.OutputSourceLine; // Act var copied_record = (CredCard2Record)cred_card2_record.Copy(); copied_record.Date = copied_record.Date.AddDays(1); copied_record.Amount = copied_record.Amount + 1; copied_record.Description = copied_record.Description + "something else"; copied_record.Update_source_line_for_output(','); // Assert Assert.AreEqual(original_date, cred_card2_record.Date); Assert.AreEqual(original_amount, cred_card2_record.Amount); Assert.AreEqual(original_description, cred_card2_record.Description); Assert.AreEqual(original_source_line, cred_card2_record.OutputSourceLine); }
public void Will_create_single_match_with_multiple_candidates_whose_total_sum_is_too_small() { // Arrange var amount_to_match = 40.00; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Unreconciled_amount = 10.00, Description = "Match01", Date = DateTime.Today }, new CredCard2InOutRecord { Unreconciled_amount = 10.00, Description = "Match02", Date = DateTime.Today }, new CredCard2InOutRecord { Unreconciled_amount = 10.00, Description = "Match03", Date = DateTime.Today } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.AreEqual(1, result.Count); Assert.AreEqual(3, result[0].Actual_records.Count); Assert.AreEqual(candidate_rows[0], result[0].Actual_records[0]); Assert.AreEqual(candidate_rows[1], result[0].Actual_records[1]); Assert.AreEqual(candidate_rows[2], result[0].Actual_records[2]); }
public void Given_all_candidates_sum_to_less_than_target_then_only_one_result_is_returned() { // Arrange var amount_to_match = 55.00; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 20.00, Description = "Match01" }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 10.00, Description = "Match02" }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 10.00, Description = "Match03" }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 10.00, Description = "Match04" } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.AreEqual(1, result.Count); }
public void Will_find_exact_matches_when_numbers_are_prone_to_rounding_errors() { // Arrange var amount_to_match = 66.57; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Unreconciled_amount = 13.00, Description = "Match01", Date = DateTime.Today.AddDays(-2) }, new CredCard2InOutRecord { Unreconciled_amount = 10.65, Description = "Match02", Date = DateTime.Today.AddDays(-1) }, new CredCard2InOutRecord { Unreconciled_amount = 29.94, Description = "Match03", Date = DateTime.Today.AddDays(0) }, new CredCard2InOutRecord { Unreconciled_amount = 13.50, Description = "Match04", Date = DateTime.Today.AddDays(1) }, new CredCard2InOutRecord { Unreconciled_amount = 14.38, Description = "Match05", Date = DateTime.Today.AddDays(2) }, new CredCard2InOutRecord { Unreconciled_amount = 12.98, Description = "Match06", Date = DateTime.Today.AddDays(3) }, new CredCard2InOutRecord { Unreconciled_amount = 46.49, Description = "Match07", Date = DateTime.Today.AddDays(4) }, new CredCard2InOutRecord { Unreconciled_amount = 20.00, Description = "Match08", Date = DateTime.Today.AddDays(9) }, new CredCard2InOutRecord { Unreconciled_amount = 20.00, Description = "Match09", Date = DateTime.Today.AddDays(9) }, new CredCard2InOutRecord { Unreconciled_amount = 20.00, Description = "Match10", Date = DateTime.Today.AddDays(9) }, new CredCard2InOutRecord { Unreconciled_amount = 20.00, Description = "Match11", Date = DateTime.Today.AddDays(9) }, new CredCard2InOutRecord { Unreconciled_amount = 50.00, Description = "Match12", Date = DateTime.Today.AddDays(9) } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.IsTrue(amount_to_match.Double_equals((result[0].Actual_records.Sum(x => x.Main_amount()))), $"Expected {result[0].Actual_records.Sum(x => x.Main_amount())} to equal {amount_to_match}"); }
public void M_WhenMatchingSpecifiedRecords_AndMultipleMatchesExist_WillRemoveOriginalMatchesFromOwnedFile() { // Arrange var matcher = new CredCard2AndCredCard2InOutMatcher(this); var source_record = new CredCard2Record { Date = DateTime.Today, Amount = 34.56, Match = null, Matched = false }; var bank_records = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Description = "Match 01", Unreconciled_amount = 20.22 }, new CredCard2InOutRecord { Description = "Match 02", Unreconciled_amount = 30.33 }, new CredCard2InOutRecord { Description = "Match 02", Unreconciled_amount = 40.44 } }; var mock_cred_card2_in_out_file_io = new Mock <IFileIO <CredCard2InOutRecord> >(); mock_cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(bank_records); var cred_card2_in_out_file = new CSVFile <CredCard2InOutRecord>(mock_cred_card2_in_out_file_io.Object); cred_card2_in_out_file.Load(); var potential_matches = new List <IPotentialMatch> { new PotentialMatch { Actual_records = new List <ICSVRecord>() } }; potential_matches[0].Actual_records.Add(bank_records[0]); potential_matches[0].Actual_records.Add(bank_records[1]); potential_matches[0].Actual_records.Add(bank_records[2]); var index = 0; var record_for_matching = new RecordForMatching <CredCard2Record>(source_record, potential_matches); foreach (var bank_record in bank_records) { Assert.IsTrue(cred_card2_in_out_file.Records.Contains(bank_record)); } // Act matcher.Match_specified_records(record_for_matching, index, cred_card2_in_out_file); // Assert foreach (var bank_record in bank_records) { Assert.IsFalse(cred_card2_in_out_file.Records.Contains(bank_record)); } }
public void Should_be_able_to_cope_with_empty_input() { // Arrange var cred_card2_record = new CredCard2Record(); string csv_line = String.Empty; // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(0, cred_card2_record.Amount); }
public void Can_cope_with_empty_description() { // Arrange var cred_card2_record = new CredCard2Record(); string csv_line = String.Format("08/06/2017,,Ms Pippi Long,ref,13.49"); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual("", cred_card2_record.Description); }
public void Can_cope_with_empty_amount() { // Arrange var cred_card2_record = new CredCard2Record(); string csv_line = String.Format("08/06/2017,ACME UK HOLDINGS,Ms Pippi Long,ref,"); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(0, cred_card2_record.Amount); }
public void Can_cope_with_bad_amount() { // Arrange var cred_card2_record = new CredCard2Record(); var bad_amount = "not an amount"; string csv_line = String.Format("08/06/2017,ref,{0},ACME UK HOLDINGS", bad_amount); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(0, cred_card2_record.Amount); }
public void Can_cope_with_empty_date() { // Arrange var cred_card2_record = new CredCard2Record(); var expected_date = new DateTime(9999, 9, 9); string csv_line = String.Format(",ACME UK HOLDINGS,Ms Pippi Long,ref,13.49"); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(expected_date, cred_card2_record.Date); }
public void Can_read_description_from_csv() { // Arrange var cred_card2_record = new CredCard2Record(); var expected_description = "ACME UK HOLDINGS"; string csv_line = String.Format("08/06/2017,{0},Ms Pippi Long,ref,13.49", expected_description); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(expected_description, cred_card2_record.Description); }
public void Commas_in_input_are_replaced_by_semi_colons() { // Arrange var cred_card2_record = new CredCard2Record(); string text_containing_commas = "something, something, something else"; string csv_line = String.Format("08/06/2017,{0},Ms Pippi Long,ref,13.49", text_containing_commas); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual("something; something; something else", cred_card2_record.Description); }
public void Should_be_able_to_read_negative_amounts() { // Arrange var cred_card2_record = new CredCard2Record(); var negative_amount = "-123.55"; string csv_line = String.Format("08/06/2017,ACME UK HOLDINGS,Ms Pippi Long,ref,{0}", negative_amount); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(-123.55, cred_card2_record.Amount); }
public void M_WhenMatchingSpecifiedRecords_AndMultipleMatchesExist_WillCreateNewRecordWithExplanatoryDescription() { // Arrange var mock_owned_file = new Mock <ICSVFile <CredCard2InOutRecord> >(); mock_owned_file.Setup(x => x.Records).Returns(new List <CredCard2InOutRecord>()); var matcher = new CredCard2AndCredCard2InOutMatcher(this); var source_record = new CredCard2Record { Amount = 34.56, Match = null, Matched = false }; var desc01 = "Thing 01"; var desc02 = "Thing 02"; var desc03 = "Thing 03"; var potential_matches = new List <IPotentialMatch> { new PotentialMatch { Actual_records = new List <ICSVRecord> { new CredCard2InOutRecord { Description = $"{ReconConsts.Amazon_description} {desc01}", Unreconciled_amount = 20.22 }, new CredCard2InOutRecord { Description = $"{ReconConsts.Amazon_description} {desc02}", Unreconciled_amount = 10.33 }, new CredCard2InOutRecord { Description = $"{ReconConsts.Amazon_description} {desc03}", Unreconciled_amount = 2.01 } } } }; var index = 0; var matches = potential_matches[index].Actual_records; var expected_description = $"{ReconConsts.SeveralAmazonTransactions} " + $"({desc01} {matches[0].Main_amount().To_csv_string(true)}, " + $"{desc02} {matches[1].Main_amount().To_csv_string(true)}, " + $"{desc03} {matches[2].Main_amount().To_csv_string(true)})" + $"{ReconConsts.TransactionsDontAddUp} ({potential_matches[index].Actual_records.Sum(x => x.Main_amount()).To_csv_string(true)})"; var record_for_matching = new RecordForMatching <CredCard2Record>(source_record, potential_matches); // Act matcher.SetAmazonStrings(); matcher.Match_specified_records(record_for_matching, index, mock_owned_file.Object); // Assert Assert.AreEqual(expected_description, record_for_matching.Matches[index].Actual_records[0].Description); }
public void Can_read_date_from_csv() { // Arrange var cred_card2_record = new CredCard2Record(); string expected_date_as_string = "08/06/2017"; string csv_line = String.Format("{0},ACME UK HOLDINGS,Ms Pippi Long,ref,13.49", expected_date_as_string); var expected_date = DateTime.ParseExact(expected_date_as_string, "dd/MM/yyyy", CultureInfo.InvariantCulture); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(expected_date, cred_card2_record.Date); }
public void Can_read_amount_from_csv_with_quotes_and_leading_space() { // Arrange var cred_card2_record = new CredCard2Record(); var expected_amount = 1.94; string input_amount = "\" " + expected_amount + "\""; string csv_line = String.Format("08/06/2017,ACME UK HOLDINGS,Ms Pippi Long,ref,{0}", input_amount); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(expected_amount, cred_card2_record.Amount); }
public void Can_cope_with_bad_date() { // Arrange var cred_card2_record = new CredCard2Record(); var expected_date = new DateTime(9999, 9, 9); var bad_date = "not a date"; string csv_line = String.Format("{0},ref,13.49,ACME UK HOLDINGS", bad_date); // Act cred_card2_record.Load(csv_line); // Assert Assert.AreEqual(expected_date, cred_card2_record.Date); }
public void Csv_is_constructed_correctly() { // Arrange var cred_card2_record = new CredCard2Record(); string csv_line = String.Format("08/06/2017,ACME UK HOLDINGS,Ms Pippi Long,ref,13.49"); cred_card2_record.Load(csv_line); cred_card2_record.Matched = false; // Act string constructed_csv_line = cred_card2_record.To_csv(); // Assert Assert.AreEqual("08/06/2017,£13.49,\"ACME UK HOLDINGS\"", constructed_csv_line); }
public void M_WhenMatchingSpecifiedRecords_WillMatchRecordWithSpecifiedIndex() { // Arrange var mock_owned_file = new Mock <ICSVFile <CredCard2InOutRecord> >(); mock_owned_file.Setup(x => x.Records).Returns(new List <CredCard2InOutRecord>()); var matcher = new CredCard2AndCredCard2InOutMatcher(this); var source_record = new CredCard2Record { Amount = 34.56, Match = null, Matched = false }; var potential_matches = new List <IPotentialMatch> { new PotentialMatch { Actual_records = new List <ICSVRecord> { new CredCard2InOutRecord { Matched = false } } }, new PotentialMatch { Actual_records = new List <ICSVRecord> { new CredCard2InOutRecord { Matched = false } } }, new PotentialMatch { Actual_records = new List <ICSVRecord> { new CredCard2InOutRecord { Matched = false } } } }; var record_for_matching = new RecordForMatching <CredCard2Record>(source_record, potential_matches); var index = 1; // Act matcher.Match_specified_records(record_for_matching, index, mock_owned_file.Object); // Assert Assert.AreEqual(false, record_for_matching.Matches[0].Actual_records[0].Matched, "first record not matched"); Assert.AreEqual(true, record_for_matching.Matches[1].Actual_records[0].Matched, "second record matched"); Assert.AreEqual(false, record_for_matching.Matches[2].Actual_records[0].Matched, "third record not matched"); }
public void If_main_amount_already_positive_then_making_it_positive_has_no_effect() { // Arrange var cred_card2_record = new CredCard2Record(); var positive_amount = 23.23; string input_amount = positive_amount.ToString(); string csv_line = String.Format("08/06/2017,ACME UK HOLDINGS,Ms Pippi Long,ref,{0}", input_amount); cred_card2_record.Load(csv_line); // Act cred_card2_record.Make_main_amount_positive(); // Assert Assert.AreEqual(positive_amount, cred_card2_record.Amount); }
public void Can_make_main_amount_positive() { // Arrange var cred_card2_record = new CredCard2Record(); var negative_amount = -23.23; string input_amount = "-" + negative_amount * -1; string csv_line = String.Format("08/06/2017,ACME UK HOLDINGS,Ms Pippi Long,ref,{0}", input_amount); cred_card2_record.Load(csv_line); // Act cred_card2_record.Make_main_amount_positive(); // Assert Assert.AreEqual(negative_amount * -1, cred_card2_record.Amount); }
public void Will_read_from_cred_card2_record_cells() { // Arrange DateTime expected_date = new DateTime(year: 2018, month: 3, day: 22); Double expected_amount = 12.38; String expected_description = "some data"; var cred_card2_record = new CredCard2Record(); var cells = _spreadsheet.Read_last_row("CredCard2"); // Act cred_card2_record.Read_from_spreadsheet_row(cells); // Assert Assert.AreEqual(expected_date, cred_card2_record.Date); Assert.AreEqual(expected_amount, cred_card2_record.Amount); Assert.AreEqual(expected_description, cred_card2_record.Description); }
public void Amounts_should_be_written_using_pound_signs() { // Arrange var cred_card2_record = new CredCard2Record(); var amount = "123.55"; var amount_with_pound_sign = "£" + amount; string csv_line = String.Format("08/06/2017,ACME UK HOLDINGS,Ms Pippi Long,ref,{0}", amount); cred_card2_record.Load(csv_line); // Act string constructed_csv_line = cred_card2_record.To_csv(); // Assert string expected_csv_line = String.Format("08/06/2017,{0},\"ACME UK HOLDINGS\"", amount_with_pound_sign); Assert.AreEqual(expected_csv_line, constructed_csv_line); }
public void Exact_matches_will_have_zero_amount_ranking() { // Arrange var amount_to_match = 40.00; CredCard2Record transaction_to_match = new CredCard2Record { Amount = amount_to_match, Date = DateTime.Today }; var desc01 = "Match01"; var desc02 = "Match02"; var desc03 = "Match03"; var desc04 = "Match04"; var desc05 = "Match05"; List <CredCard2InOutRecord> candidate_rows = new List <CredCard2InOutRecord> { new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 20.00, Description = desc01 }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 20.00, Description = desc02 }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 10.00, Description = desc03 }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 10.00, Description = desc04 }, new CredCard2InOutRecord { Date = DateTime.Today, Unreconciled_amount = 5.00, Description = desc05 } }; _cred_card2_in_out_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)).Returns(candidate_rows); _cred_card2_in_out_file.Load(); var matcher = new MultipleAmountMatcher <CredCard2Record, CredCard2InOutRecord>(); // Act var result = matcher.Find_matches(transaction_to_match, _cred_card2_in_out_file).ToList(); // Assert Assert.AreEqual(3, result.Count(x => x.Rankings.Amount == 0)); Assert.AreEqual(0, result[0].Rankings.Amount); Assert.AreEqual(0, result[1].Rankings.Amount); Assert.AreEqual(0, result[2].Rankings.Amount); }
public void M_WhenMatchingSpecifiedRecords_AndMultipleMatchesAreChosen_AndSummedAmountsDontMatch_WillMarkDiscrepancy() { // Arrange var mock_owned_file = new Mock <ICSVFile <CredCard2InOutRecord> >(); mock_owned_file.Setup(x => x.Records).Returns(new List <CredCard2InOutRecord>()); var matcher = new CredCard2AndCredCard2InOutMatcher(this); var potential_matches = new List <IPotentialMatch> { new PotentialMatch { Actual_records = new List <ICSVRecord> { new CredCard2InOutRecord { Description = "Match 01", Unreconciled_amount = 20.22 }, new CredCard2InOutRecord { Description = "Match 02", Unreconciled_amount = 30.33 }, new CredCard2InOutRecord { Description = "Match 02", Unreconciled_amount = 40.44 } } } }; var index = 0; var matches = potential_matches[index].Actual_records; var expected_amount = matches[0].Main_amount() + matches[1].Main_amount() + matches[2].Main_amount(); var source_record = new CredCard2Record { Date = DateTime.Today, Amount = expected_amount + 10, Match = null, Matched = false }; var record_for_matching = new RecordForMatching <CredCard2Record>(source_record, potential_matches); // Act matcher.Match_specified_records(record_for_matching, index, mock_owned_file.Object); // Assert Assert.IsTrue(record_for_matching.Matches[index].Actual_records[0].Description.Contains(ReconConsts.TransactionsDontAddUp)); }