public void Csv_is_constructed_correctly() { // Arrange var cred_card1_record = new CredCard1Record(); string csv_line = String.Format("17/02/2017,23/11/2018,22223333,ANY STORE,12.33"); cred_card1_record.Load(csv_line); cred_card1_record.Matched = false; // Act string constructed_csv_line = cred_card1_record.To_csv(); // Assert Assert.AreEqual("17/02/2017,£12.33,\"ANY STORE\"", constructed_csv_line); }
public void Amounts_will_come_in_positive_and_stay_positive() { // Arrange var cred_card1_record = new CredCard1Record(); var expectedAmount = 12.33; string csv_line = String.Format($"17/02/2017,23/11/2018,22223333,ANY STORE,{expectedAmount}"); cred_card1_record.Load(csv_line); cred_card1_record.Matched = false; // Act string constructed_csv_line = cred_card1_record.To_csv(); // Assert Assert.AreEqual(expectedAmount, cred_card1_record.Amount); }
public void Amounts_should_be_written_using_pound_signs() { // Arrange var cred_card1_record = new CredCard1Record(); var amount = "123.55"; var amount_with_pound_sign = "£" + amount; string csv_line = String.Format("17/02/2017,23/11/2018,22223333,ANY STORE,{0}", amount); cred_card1_record.Load(csv_line); // Act string constructed_csv_line = cred_card1_record.To_csv(); // Assert string expected_csv_line = String.Format("17/02/2017,{0},\"ANY STORE\"", 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_card1_record = new CredCard1Record(); var amount = 1234.55; var amount_containing_comma = "£1,234.55"; string csv_line = String.Format("17/02/2017,23/11/2018,22223333,ANY STORE,{0}", amount); cred_card1_record.Load(csv_line); // Act string constructed_csv_line = cred_card1_record.To_csv(); // Assert string expected_csv_line = String.Format("17/02/2017,\"{0}\",\"ANY STORE\"", amount_containing_comma); Assert.AreEqual(expected_csv_line, constructed_csv_line); }
public void If_input_is_encased_in_quotes_then_output_only_has_one_encasing_set_of_quotes() { // Arrange var cred_card1_record = new CredCard1Record(); var description_encased_in_one_set_of_quotes = "\"ANY STORE\""; string csv_line = String.Format("17/02/2017,23/11/2018,22223333,{0},12.33", description_encased_in_one_set_of_quotes); cred_card1_record.Load(csv_line); cred_card1_record.Matched = false; // Act string constructed_csv_line = cred_card1_record.To_csv(); // Assert var expected_csv_line = String.Format("17/02/2017,£12.33,{0}", description_encased_in_one_set_of_quotes); Assert.AreEqual(expected_csv_line, constructed_csv_line); }