public void When_copying_record_will_create_new_object() { // Arrange var original_date = DateTime.Today; var original_unreconciled_amount = 12.34; var original_description = "Description"; var original_reconciled_amount = 56.78; var original_source_line = "SourceLine"; var cred_card2_in_out_record = new CredCard2InOutRecord { Date = original_date, Unreconciled_amount = original_unreconciled_amount, Description = original_description, Reconciled_amount = original_reconciled_amount, OutputSourceLine = original_source_line }; // Act var copied_record = (CredCard2InOutRecord)cred_card2_in_out_record.Copy(); copied_record.Date = copied_record.Date.AddDays(1); copied_record.Unreconciled_amount = copied_record.Unreconciled_amount + 1; copied_record.Description = copied_record.Description + "something else"; copied_record.Reconciled_amount = copied_record.Reconciled_amount + 1; copied_record.OutputSourceLine = copied_record.OutputSourceLine + "something else"; // Assert Assert.AreEqual(original_date, cred_card2_in_out_record.Date); Assert.AreEqual(original_unreconciled_amount, cred_card2_in_out_record.Unreconciled_amount); Assert.AreEqual(original_description, cred_card2_in_out_record.Description); Assert.AreEqual(original_reconciled_amount, cred_card2_in_out_record.Reconciled_amount); Assert.AreEqual(original_source_line, cred_card2_in_out_record.OutputSourceLine); }
public void Will_populate_zero_amounts_as_empty_cred_card2_in_out_record_cells() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord { Unreconciled_amount = 0, Reconciled_amount = 0 }; var cells = _spreadsheet.Current_cells("CredCard"); var last_row_number = _spreadsheet.Last_row_number("CredCard"); var previous_record = new CredCard2InOutRecord(); previous_record.Read_from_spreadsheet_row(_spreadsheet.Read_last_row("CredCard")); // Act cred_card2_in_out_record.Populate_spreadsheet_row(cells, last_row_number); var new_row = _spreadsheet.Read_last_row("CredCard"); // Assert Assert.AreEqual(null, new_row.Read_cell(1)); Assert.AreEqual(null, new_row.Read_cell(4)); // Clean up previous_record.Populate_spreadsheet_row(cells, last_row_number); }
public void Will_populate_cred_card2_in_out_record_cells() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord { Date = new DateTime(year: 2017, month: 4, day: 1), Unreconciled_amount = 22.48, Description = "New description which will overwrite what's normally there.", Reconciled_amount = 661234.56 }; var cells = _spreadsheet.Current_cells("CredCard"); var last_row_number = _spreadsheet.Last_row_number("CredCard"); var previous_record = new CredCard2InOutRecord(); previous_record.Read_from_spreadsheet_row(_spreadsheet.Read_last_row("CredCard")); // Act cred_card2_in_out_record.Populate_spreadsheet_row(cells, last_row_number); var new_row = _spreadsheet.Read_last_row("CredCard"); // Assert Assert.AreEqual(cred_card2_in_out_record.Date, DateTime.FromOADate((double)new_row.Read_cell(0))); Assert.AreEqual(cred_card2_in_out_record.Unreconciled_amount, (Double)new_row.Read_cell(1)); Assert.AreEqual(cred_card2_in_out_record.Description, (String)new_row.Read_cell(3)); Assert.AreEqual(cred_card2_in_out_record.Reconciled_amount, (Double)new_row.Read_cell(4)); // Clean up previous_record.Populate_spreadsheet_row(cells, last_row_number); }
private void Assert_direct_debit_details_are_correct( CredCard2InOutRecord cred_card2_in_out_record, DateTime expected_date, double expected_amount, string expected_description) { Assert.AreEqual(expected_description, cred_card2_in_out_record.Description); Assert.AreEqual(expected_date, cred_card2_in_out_record.Date); Assert.AreEqual(expected_amount, cred_card2_in_out_record.Unreconciled_amount); }
public void Will_add_default_description_if_description_is_unpopulated() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); string csv_line = "19/12/2016^£123.55^^^"; // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual("Source record had no description", cred_card2_in_out_record.Description); }
public void Can_read_amount_containing_comma_from_csv() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); string csv_line = "19/12/2016^£5,678.99^^ZZZSpecialDescription017^"; // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(5678.99, cred_card2_in_out_record.Unreconciled_amount); }
public void Can_cope_with_empty_reconciled_amount() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); string csv_line = String.Format("19/04/2017^^^Acme: Esmerelda's birthday^"); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(0, cred_card2_in_out_record.Reconciled_amount); }
public void Should_be_able_to_cope_with_empty_input() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); string csv_line = String.Empty; // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(0, cred_card2_in_out_record.Reconciled_amount); }
public void Can_cope_with_empty_date() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var expected_date = new DateTime(9999, 9, 9); string csv_line = String.Format("^£13.48^^Acme: Esmerelda's birthday^"); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(expected_date, cred_card2_in_out_record.Date); }
public void Should_be_able_to_read_negative_amounts() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var negative_amount = "-£123.55"; string csv_line = String.Format("19/04/2017^£13.48^^Acme: Esmerelda's birthday^{0}", negative_amount); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(-123.55, cred_card2_in_out_record.Reconciled_amount); }
public void Can_read_data_from_csv_with_extra_separator_at_end() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var expected_description = "ZZZSpecialDescription017"; string csv_line = String.Format("19/12/2016^£7.99^^{0}^^", expected_description); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(expected_description, cred_card2_in_out_record.Description); }
private CredCard2InOutRecord New_combined_record( RecordForMatching <CredCard2Record> record_for_matching, int match_index) { var new_match = new CredCard2InOutRecord { Date = record_for_matching.SourceRecord.Date, Description = Create_new_description(record_for_matching, match_index) }; new_match.Unreconciled_amount = record_for_matching.SourceRecord.Main_amount(); return(new_match); }
public void Will_populate_source_line_when_reading_from_cred_card2_in_out_record_cells() { // Arrange String expected_source_line = String.Format("27/04/2018^£5.10^^pintipoplication^\"£10,567.89\"^"); var cred_card2_in_out_record = new CredCard2InOutRecord(); var cells = _spreadsheet.Read_last_row("CredCard"); // Act cred_card2_in_out_record.Read_from_spreadsheet_row(cells); // Assert Assert.AreEqual(expected_source_line, cred_card2_in_out_record.OutputSourceLine); }
public void Should_be_able_to_read_amounts_preceded_by_pound_signs() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var amount_with_pound_sign = "£1,234.55"; string csv_line = String.Format("19/04/2017^£13.48^^Acme: Esmerelda's birthday^{0}", amount_with_pound_sign); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(1234.55, cred_card2_in_out_record.Reconciled_amount); }
public void Should_be_able_to_read_unreconciled_amounts_containing_commas() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var amount_containing_comma = "£1,234.55"; string csv_line = String.Format("19/04/2017^{0}^^Acme: Esmerelda's birthday^", amount_containing_comma); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(1234.55, cred_card2_in_out_record.Unreconciled_amount); }
public void Can_read_description_from_csv() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var expected_description = "Acme: Esmerelda's birthday"; string csv_line = String.Format("19/04/2017^£13.48^^{0}^", expected_description); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(expected_description, cred_card2_in_out_record.Description); }
public void Can_read_date_from_csv() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); string expected_date_as_string = "01/04/2017"; string csv_line = String.Format("{0}^£13.48^^Acme: Esmerelda's birthday^", expected_date_as_string); var expected_date = Convert.ToDateTime(expected_date_as_string, StringHelper.Culture()); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(expected_date, cred_card2_in_out_record.Date); }
public void Can_read_unreconciled_amount_from_csv() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var expected_amount = 13.95; string input_amount = "£" + expected_amount; string csv_line = String.Format("19/04/2017^{0}^^Acme: Esmerelda's birthday^", input_amount); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(expected_amount, cred_card2_in_out_record.Unreconciled_amount); }
public void Can_read_amount_surrounded_by_quotes_from_csv() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); double expected_amount = 7888.99; string input_amount = "£" + expected_amount; string csv_line = String.Format("19/12/2016^\"{0}\"^^ZZZSpecialDescription017^", input_amount); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(expected_amount, cred_card2_in_out_record.Unreconciled_amount); }
public void Csv_is_constructed_correctly_without_matched_record() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); string csv_line = String.Format("19/04/2017^£13.48^^Acme: Esmerelda's birthday^£33.44"); cred_card2_in_out_record.Load(csv_line); cred_card2_in_out_record.Matched = true; // Act string constructed_csv_line = cred_card2_in_out_record.To_csv(); // Assert Assert.AreEqual("19/04/2017,£13.48,x,\"Acme: Esmerelda's birthday\",£33.44,", constructed_csv_line); }
public void Empty_fields_are_output_as_nothing_for_csv() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); string csv_line = String.Format("19/04/2017^^^Acme: Esmerelda's birthday^"); cred_card2_in_out_record.Load(csv_line); cred_card2_in_out_record.Matched = true; // Act string constructed_csv_line = cred_card2_in_out_record.To_csv(); // Assert Assert.AreEqual("19/04/2017,,x,\"Acme: Esmerelda's birthday\",,", constructed_csv_line); }
public void Create_new_combined_record( RecordForMatching <CredCard2Record> record_for_matching, int match_index, ICSVFile <CredCard2InOutRecord> owned_file) { foreach (var actual_record in record_for_matching.Matches[match_index].Actual_records) { owned_file.Remove_record_permanently((CredCard2InOutRecord)actual_record); } CredCard2InOutRecord new_match = New_combined_record(record_for_matching, match_index); record_for_matching.Matches[match_index].Actual_records.Clear(); record_for_matching.Matches[match_index].Actual_records.Add(new_match); owned_file.Add_record_permanently(new_match); }
public void Can_cope_with_input_containing_commas_preceded_by_spaces() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); double expected_amount = 12.35; string input_amount = "£" + expected_amount; string text_containing_commas = "something ,something ,something else"; string csv_line = String.Format("19/04/2017^^^{0}^{1}", text_containing_commas, input_amount); // Act cred_card2_in_out_record.Load(csv_line); // Assert Assert.AreEqual(expected_amount, cred_card2_in_out_record.Reconciled_amount); }
public void Can_make_main_amount_positive() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var negative_amount = -23.23; string input_amount = "-£" + negative_amount * -1; string csv_line = String.Format("19/04/2017^{0}^^Acme: Esmerelda's birthday^", input_amount); cred_card2_in_out_record.Load(csv_line); // Act cred_card2_in_out_record.Make_main_amount_positive(); // Assert Assert.AreEqual(negative_amount * -1, cred_card2_in_out_record.Unreconciled_amount); }
public void If_main_amount_already_positive_then_making_it_positive_has_no_effect() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var positive_amount = 23.23; string input_amount = "£" + positive_amount; string csv_line = String.Format("19/04/2017^{0}^^Acme: Esmerelda's birthday^", input_amount); cred_card2_in_out_record.Load(csv_line); // Act cred_card2_in_out_record.Make_main_amount_positive(); // Assert Assert.AreEqual(positive_amount, cred_card2_in_out_record.Unreconciled_amount); }
public void Amounts_should_be_written_using_pound_signs() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var amount_with_pound_sign = "£123.55"; string csv_line = String.Format("19/04/2017^{0}^^Acme: Esmerelda's birthday^", amount_with_pound_sign); cred_card2_in_out_record.Load(csv_line); // Act string constructed_csv_line = cred_card2_in_out_record.To_csv(); // Assert string expected_csv_line = String.Format("19/04/2017,{0},,\"Acme: Esmerelda's birthday\",,", amount_with_pound_sign); Assert.AreEqual(expected_csv_line, constructed_csv_line); }
public void Amounts_containing_commas_should_be_encased_in_quotes() { // Arrange var cred_card2_in_out_record = new CredCard2InOutRecord(); var amount_containing_comma = "£1,234.55"; string csv_line = String.Format("19/04/2017^{0}^^Acme: Esmerelda's birthday^", amount_containing_comma); cred_card2_in_out_record.Load(csv_line); // Act string constructed_csv_line = cred_card2_in_out_record.To_csv(); // Assert string expected_csv_line = String.Format("19/04/2017,\"{0}\",,\"Acme: Esmerelda's birthday\",,", amount_containing_comma); Assert.AreEqual(expected_csv_line, constructed_csv_line); }
public void Will_read_from_cred_card2_in_out_record_cells_when_there_is_a_null_reconciled_amount() { // Arrange DateTime expected_date = new DateTime(year: 2018, month: 4, day: 25); Double expected_unreconciled_amount = 4.90; String expected_description = "pintipoplication"; Double expected_reconciled_amount = 0; var cred_card2_in_out_record = new CredCard2InOutRecord(); var cells = _spreadsheet.Read_specified_row("CredCard", 8); // Act cred_card2_in_out_record.Read_from_spreadsheet_row(cells); // Assert Assert.AreEqual(expected_date, cred_card2_in_out_record.Date); Assert.AreEqual(expected_unreconciled_amount, cred_card2_in_out_record.Unreconciled_amount); Assert.AreEqual(expected_description, cred_card2_in_out_record.Description); Assert.AreEqual(expected_reconciled_amount, cred_card2_in_out_record.Reconciled_amount); }
public void Will_cope_with_cred_card2_in_out_cells_when_not_all_cells_are_populated() { // Arrange String expected_description = "SOMETHING EXCITING & SOMEWHERE COOL"; var cred_card2_in_out_record = new CredCard2InOutRecord(); List <object> cells = new List <object> { (double)43405, null, null, expected_description }; // Act cred_card2_in_out_record.Read_from_spreadsheet_row(new ExcelRow(cells)); // Assert Assert.AreEqual(expected_description, cred_card2_in_out_record.Description); }
public void Will_read_from_cred_card2_in_out_record_cells() { // Arrange DateTime expected_date = new DateTime(year: 2018, month: 4, day: 27); Double expected_unreconciled_amount = 5.10; String expected_description = "pintipoplication"; Double expected_reconciled_amount = 10567.89; var cred_card2_in_out_record = new CredCard2InOutRecord(); var cells = _spreadsheet.Read_last_row("CredCard"); // Act cred_card2_in_out_record.Read_from_spreadsheet_row(cells); // Assert Assert.AreEqual(expected_date, cred_card2_in_out_record.Date); Assert.AreEqual(expected_unreconciled_amount, cred_card2_in_out_record.Unreconciled_amount); Assert.AreEqual(expected_description, cred_card2_in_out_record.Description); Assert.AreEqual(expected_reconciled_amount, cred_card2_in_out_record.Reconciled_amount); }