public void Can_delete_specified_rows()
        {
            // Arrange
            var    sheet_name  = TestSheetNames.Cred_card;
            var    test_record = new CredCard1InOutRecord();
            string csv_line    = String.Format("19/12/2016^£12.34^^Bantams^£33.44^");

            test_record.Load(csv_line);
            var    last_row                = new CredCard1InOutRecord();
            string expected_last_row       = "27/04/2018,£5.10,,\"pintipoplication\",\"£10,567.89\",";
            var    initial_last_row_number = _excelSpreadsheet.Last_row_number(sheet_name);

            _excelSpreadsheet.Append_csv_record(sheet_name, test_record);
            _excelSpreadsheet.Append_csv_record(sheet_name, test_record);

            // Act
            _excelSpreadsheet.Delete_specified_rows(sheet_name, 12, 13);

            // Assert
            var new_last_row        = _excelSpreadsheet.Read_last_row_as_csv(sheet_name, last_row);
            var new_last_row_number = _excelSpreadsheet.Last_row_number(sheet_name);

            Assert.AreEqual(new_last_row_number, initial_last_row_number);
            Assert.AreEqual(expected_last_row, new_last_row);
        }
Exemplo n.º 2
0
        public void Will_add_default_description_if_description_is_unpopulated()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string csv_line = "19/12/2016^£123.55^^^";

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual("Source record had no description", cred_card1_in_out_record.Description);
        }
Exemplo n.º 3
0
        public void Can_cope_with_empty_reconciled_amount()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string csv_line = String.Format("19/12/2016^£7.99^^ZZZSpecialDescription017^");

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(0, cred_card1_in_out_record.Reconciled_amount);
        }
Exemplo n.º 4
0
        public void Can_read_amount_containing_comma_from_csv()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string csv_line = "19/12/2016^£5,678.99^^ZZZSpecialDescription017^";

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(5678.99, cred_card1_in_out_record.Unreconciled_amount);
        }
Exemplo n.º 5
0
        public void Should_be_able_to_cope_with_empty_input()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string csv_line = String.Empty;

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(0, cred_card1_in_out_record.Reconciled_amount);
        }
Exemplo n.º 6
0
        public void Can_cope_with_bad_unreconciled_amount()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    bad_amount = "not an amount";
            string csv_line   = String.Format("19/12/2016^{0}^^ZZZSpecialDescription017^", bad_amount);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(0, cred_card1_in_out_record.Unreconciled_amount);
        }
Exemplo n.º 7
0
        public void Can_cope_with_empty_date()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    expected_date            = new DateTime(9999, 9, 9);
            string csv_line = String.Format("^£7.99^^ZZZSpecialDescription017^");

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(expected_date, cred_card1_in_out_record.Date);
        }
Exemplo n.º 8
0
        public void Can_read_description_from_csv()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    expected_description     = "ZZZSpecialDescription017";
            string csv_line = String.Format("19/12/2016^£7.99^^{0}^", expected_description);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(expected_description, cred_card1_in_out_record.Description);
        }
Exemplo n.º 9
0
        public void Should_be_able_to_read_reconciled_amounts_containing_commas()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    amount_containing_comma  = "£1,234.55";
            string csv_line = String.Format("19/12/2016^^^ZZZSpecialDescription017^{0}", amount_containing_comma);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(1234.55, cred_card1_in_out_record.Reconciled_amount);
        }
Exemplo n.º 10
0
        public void Should_be_able_to_read_negative_amounts()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    negative_amount          = "-£123.55";
            string csv_line = String.Format("19/12/2016^^^ZZZSpecialDescription017^{0}", negative_amount);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(-123.55, cred_card1_in_out_record.Reconciled_amount);
        }
Exemplo n.º 11
0
        public void Should_be_able_to_read_amounts_preceded_by_pound_signs()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    amount_with_pound_sign   = "£1,234.55";
            string csv_line = String.Format("19/12/2016^{0}^^ZZZSpecialDescription017^", amount_with_pound_sign);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(1234.55, cred_card1_in_out_record.Unreconciled_amount);
        }
Exemplo n.º 12
0
        public void Can_read_date_from_csv()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string expected_date_as_string  = "19/12/2016";
            string csv_line      = String.Format("{0}^£7.99^^ZZZSpecialDescription017^", expected_date_as_string);
            var    expected_date = Convert.ToDateTime(expected_date_as_string, StringHelper.Culture());

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(expected_date, cred_card1_in_out_record.Date);
        }
Exemplo n.º 13
0
        public void Can_read_amount_surrounded_by_quotes_from_csv()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            double expected_amount          = 7888.99;
            string input_amount             = "£" + expected_amount;
            string csv_line = String.Format("19/12/2016^\"{0}\"^^ZZZSpecialDescription017^", input_amount);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(expected_amount, cred_card1_in_out_record.Unreconciled_amount);
        }
Exemplo n.º 14
0
        public void Can_read_reconciled_amount_from_csv()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    expected_amount          = 238.92;
            string input_amount             = "£" + expected_amount;
            string csv_line = String.Format("19/12/2016^£7.99^^ZZZSpecialDescription017^{0}", input_amount);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(expected_amount, cred_card1_in_out_record.Reconciled_amount);
        }
Exemplo n.º 15
0
        public void Can_cope_with_input_containing_commas_preceded_by_spaces()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            double expected_amount          = 12.35;
            string input_amount             = "£" + expected_amount;
            string text_containing_commas   = "something ,something ,something else";
            string csv_line = String.Format("19/12/2016^^^{0}^{1}", text_containing_commas, input_amount);

            // Act
            cred_card1_in_out_record.Load(csv_line);

            // Assert
            Assert.AreEqual(expected_amount, cred_card1_in_out_record.Reconciled_amount);
        }
Exemplo n.º 16
0
        public void Empty_fields_are_output_as_nothing_for_csv()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string csv_line = String.Format("19/12/2016^^^Bantams^^");

            cred_card1_in_out_record.Load(csv_line);
            cred_card1_in_out_record.Matched = false;

            // Act
            string constructed_csv_line = cred_card1_in_out_record.To_csv();

            // Assert
            Assert.AreEqual("19/12/2016,,,\"Bantams\",,", constructed_csv_line);
        }
Exemplo n.º 17
0
        public void Csv_is_constructed_correctly_without_matched_record()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string csv_line = String.Format("19/12/2016^£12.34^^Bantams^£33.44^");

            cred_card1_in_out_record.Load(csv_line);
            cred_card1_in_out_record.Matched = false;

            // Act
            string constructed_csv_line = cred_card1_in_out_record.To_csv();

            // Assert
            Assert.AreEqual("19/12/2016,£12.34,,\"Bantams\",£33.44,", constructed_csv_line);
        }
Exemplo n.º 18
0
        public void Can_make_main_amount_positive()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    negative_amount          = -23.23;
            string input_amount             = "-£" + negative_amount * -1;
            string csv_line = String.Format("19/12/2016^{0}^^ZZZSpecialDescription017^", input_amount);

            cred_card1_in_out_record.Load(csv_line);

            // Act
            cred_card1_in_out_record.Make_main_amount_positive();

            // Assert
            Assert.AreEqual(negative_amount * -1, cred_card1_in_out_record.Unreconciled_amount);
        }
Exemplo n.º 19
0
        public void If_main_amount_already_positive_then_making_it_positive_has_no_effect()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    positive_amount          = 23.23;
            string input_amount             = "£" + positive_amount;
            string csv_line = String.Format("19/12/2016^{0}^^ZZZSpecialDescription017^", input_amount);

            cred_card1_in_out_record.Load(csv_line);

            // Act
            cred_card1_in_out_record.Make_main_amount_positive();

            // Assert
            Assert.AreEqual(positive_amount, cred_card1_in_out_record.Unreconciled_amount);
        }
Exemplo n.º 20
0
        public void Amounts_should_be_written_using_pound_signs()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    amount_with_pound_sign   = "£123.55";
            string csv_line = String.Format("19/12/2016^{0}^^Bantams^", amount_with_pound_sign);

            cred_card1_in_out_record.Load(csv_line);

            // Act
            string constructed_csv_line = cred_card1_in_out_record.To_csv();

            // Assert
            string expected_csv_line = String.Format("19/12/2016,{0},,\"Bantams\",,", amount_with_pound_sign);

            Assert.AreEqual(expected_csv_line, constructed_csv_line);
        }
Exemplo n.º 21
0
        public void Amounts_containing_commas_should_be_encased_in_quotes()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            var    amount_containing_comma  = "£1,234.55";
            string csv_line = String.Format("19/12/2016^{0}^^Bantams^", amount_containing_comma);

            cred_card1_in_out_record.Load(csv_line);

            // Act
            string constructed_csv_line = cred_card1_in_out_record.To_csv();

            // Assert
            string expected_csv_line = String.Format("19/12/2016,\"{0}\",,\"Bantams\",,", amount_containing_comma);

            Assert.AreEqual(expected_csv_line, constructed_csv_line);
        }
Exemplo n.º 22
0
        public void Csv_is_constructed_correctly_with_matched_record()
        {
            // Arrange
            var    cred_card1_in_out_record = new CredCard1InOutRecord();
            string csv_line = String.Format("19/12/2016^£12.34^^Bantams^£33.44^");

            cred_card1_in_out_record.Load(csv_line);
            cred_card1_in_out_record.Matched = false;
            string matched_record_csv_line = String.Format("17/02/2017,23/11/2018,22223333,\"ANY STORE\",12.33");
            var    matched_record          = new CredCard1Record();

            matched_record.Load(matched_record_csv_line);
            cred_card1_in_out_record.Match = matched_record;

            // Act
            string constructed_csv_line = cred_card1_in_out_record.To_csv();

            // Assert
            Assert.AreEqual("19/12/2016,£12.34,,\"Bantams\",£33.44,,,17/02/2017,£12.33,\"ANY STORE\"", constructed_csv_line);
        }