public void Will_mark_last_bank_out_row_when_loading_before_records_are_ordered_in_date_order() { // Arrange string last_row_description = "Last row"; var fake_records = new List <ActualBankRecord> { new ActualBankRecord { Amount = 10, Date = new DateTime(2020, 1, 4), Description = last_row_description }, new ActualBankRecord { Amount = 10, Date = new DateTime(2020, 1, 4), Description = "This will be the last row when ordered in date order." }, new ActualBankRecord { Amount = 10, Date = new DateTime(2020, 1, 2) }, }; var mock_actual_bank_file_io = new Mock <IFileIO <ActualBankRecord> >(); mock_actual_bank_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), It.IsAny <char?>())) .Returns(fake_records); var actual_bank_file = new CSVFile <ActualBankRecord>(mock_actual_bank_file_io.Object); var actual_bank_in_file = new ActualBankInFile(actual_bank_file); // Act actual_bank_in_file.Load(); // Assert var last_record = actual_bank_in_file.File.Records.First(x => x.Description == last_row_description); Assert.AreEqual(ReconConsts.LastOnlineTransaction, last_record.LastTransactionMarker); }
public void M_WhenDoingExpenseMatchingWillFilterOwnedFileForWagesRowsAndExpenseTransactionsOnly() { // Arrange var mock_bank_and_bank_in_loader = new Mock <IBankAndBankInLoader>(); var mock_bank_in_file_io = new Mock <IFileIO <BankRecord> >(); var wages_description = $"Wages ({ReconConsts.Employer_expense_description}) (!! in an inestimable manner, not forthwith - forever 1st outstanding)"; mock_bank_in_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)) .Returns(new List <BankRecord> { new BankRecord { Type = Codes.Expenses, Description = Codes.Expenses + "1" }, new BankRecord { Type = "Chq", Description = "something" }, new BankRecord { Type = Codes.Expenses, Description = Codes.Expenses + "2" }, new BankRecord { Type = Codes.Expenses, Description = Codes.Expenses + "3" }, new BankRecord { Type = "Chq", Description = "something" }, new BankRecord { Type = "PCL", Description = wages_description } }); var bank_in_file = new GenericFile <BankRecord>(new CSVFile <BankRecord>(mock_bank_in_file_io.Object)); var mock_actual_bank_file_io = new Mock <IFileIO <ActualBankRecord> >(); mock_actual_bank_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)) .Returns(new List <ActualBankRecord> { new ActualBankRecord { Description = $"\"'{ReconConsts.Employer_expense_description}\"" } }); var actual_bank_file = new ActualBankInFile(new CSVFile <ActualBankRecord>(mock_actual_bank_file_io.Object)); var data_loading_info = new DataLoadingInformation <ActualBankRecord, BankRecord> { Sheet_name = MainSheetNames.Bank_in }; var reconciliator = new Reconciliator <ActualBankRecord, BankRecord>(data_loading_info, actual_bank_file, bank_in_file); var matcher = new BankAndBankInMatcher(this, new FakeSpreadsheetRepoFactory(), mock_bank_and_bank_in_loader.Object); // Act matcher.Filter_for_all_wages_rows_and_expense_transactions_from_expected_in(reconciliator); // Assert Assert.AreEqual(4, reconciliator.Owned_file.Records.Count); Assert.AreEqual(Codes.Expenses + "1", reconciliator.Owned_file.Records[0].Description); Assert.AreEqual(Codes.Expenses + "2", reconciliator.Owned_file.Records[1].Description); Assert.AreEqual(Codes.Expenses + "3", reconciliator.Owned_file.Records[2].Description); Assert.AreEqual(wages_description, reconciliator.Owned_file.Records[3].Description); }
public void Will_filter_for_positive_records_when_loading() { // Arrange var mock_actual_bank_file = new Mock <ICSVFile <ActualBankRecord> >(); var actual_bank_in_file = new ActualBankInFile(mock_actual_bank_file.Object); // Act actual_bank_in_file.Load(); // Assert mock_actual_bank_file.Verify(x => x.Filter_for_positive_records_only()); }
public void M_WillFilterActualBankFileForExpenseTransactionsOnly() { // Arrange var mock_bank_and_bank_in_loader = new Mock <IBankAndBankInLoader>(); var mock_actual_bank_file_io = new Mock <IFileIO <ActualBankRecord> >(); mock_actual_bank_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)) .Returns(new List <ActualBankRecord> { new ActualBankRecord { Description = $"\"'{ReconConsts.Employer_expense_description}\"" }, new ActualBankRecord { Description = "something else" } }); var actual_bank_file = new ActualBankInFile(new CSVFile <ActualBankRecord>(mock_actual_bank_file_io.Object)); var mock_bank_in_file_io = new Mock <IFileIO <BankRecord> >(); mock_bank_in_file_io.Setup(x => x.Load(It.IsAny <List <string> >(), null)) .Returns(new List <BankRecord> { new BankRecord { Type = Codes.Expenses, Description = Codes.Expenses + "1" } }); var bank_in_file = new GenericFile <BankRecord>(new CSVFile <BankRecord>(mock_bank_in_file_io.Object)); var data_loading_info = new DataLoadingInformation <ActualBankRecord, BankRecord> { Sheet_name = MainSheetNames.Bank_in }; var reconciliator = new Reconciliator <ActualBankRecord, BankRecord>(data_loading_info, actual_bank_file, bank_in_file); var matcher = new BankAndBankInMatcher(this, new FakeSpreadsheetRepoFactory(), mock_bank_and_bank_in_loader.Object); // Act matcher.Filter_for_all_expense_transactions_from_actual_bank_in(reconciliator); // Assert Assert.AreEqual(1, reconciliator.Third_party_file.Records.Count); Assert.AreEqual(ReconConsts.Employer_expense_description, reconciliator.Third_party_file.Records[0].Description.Remove_punctuation()); }