public void M_CanAddUnreconciledRowsToCredCard1InOutCsvFileAndPutInDateOrder() { // Arrange var sheet_name = "MockSheet"; double date = 43345; var amount = 22.34; var text1 = "first row"; var text2 = "second row"; var text3 = "third row"; var fake_cell_row1 = new FakeCellRow().With_fake_data(new List <object> { date, amount, null, text2 }); var fake_cell_row3 = new FakeCellRow().With_fake_data(new List <object> { date + 1, amount, null, text3 }); var fake_cell_row2 = new FakeCellRow().With_fake_data(new List <object> { date - 1, amount, null, text1 }); var mock_spreadsheet_repo = new Mock <ISpreadsheetRepo>(); mock_spreadsheet_repo.Setup(x => x.Find_row_number_of_last_row_containing_cell(sheet_name, Dividers.Divider_text, 2)) .Returns(1); mock_spreadsheet_repo.Setup(x => x.Last_row_number(sheet_name)).Returns(4); mock_spreadsheet_repo.Setup(x => x.Read_specified_row(sheet_name, 2)).Returns(fake_cell_row1); mock_spreadsheet_repo.Setup(x => x.Read_specified_row(sheet_name, 3)).Returns(fake_cell_row2); mock_spreadsheet_repo.Setup(x => x.Read_specified_row(sheet_name, 4)).Returns(fake_cell_row3); var spreadsheet = new Spreadsheet(mock_spreadsheet_repo.Object); var expected_num_records = 3; var csv_file = new CSVFileFactory <CredCard1InOutRecord>().Create_csv_file(false); // Act spreadsheet.Add_unreconciled_rows_to_csv_file <CredCard1InOutRecord>(sheet_name, csv_file); // Assert Assert.AreEqual(expected_num_records, csv_file.Records.Count); Assert.IsTrue(csv_file.Records[0].Source_line.Contains(text1), $"line 0 should contain correct text"); Assert.IsTrue(csv_file.Records[1].Source_line.Contains(text2), $"line 1 should contain correct text"); Assert.IsTrue(csv_file.Records[2].Source_line.Contains(text3), $"line 1 should contain correct text"); }