public List <ExportFile> GetExportFiles(CommaFormatter fileFormatter, List <Facility> facilities, Client client) { var exportFiles = new List <ExportFile>(); var exportDate = DateTime.Now; var accountsAboveThreshold = new List <Account>(); foreach (var facility in facilities) { var accounts = accountService.GetAllAccountsByFacilityForClient(facility, client); foreach (var account in accounts) { if (account.Balance > account.Client.BalanceThreshold) { accountsAboveThreshold.Add(account); } } var exportFile = new ExportFile { FileName = fileFormatter.FormatFileName(exportDate, facility), Content = fileFormatter.FormatContent(accountsAboveThreshold) }; exportFiles.Add(exportFile); } return(exportFiles); }
public void ICanExportCommaFormat1() { // Arrange var fileFormatter = new CommaFormatter(); var client = accountService.GetAllAccounts().Where(a => a.Client.FormatterType == FormatterType.CSV).FirstOrDefault().Client; var facilities = facilityService.GetAllFacilities(); var expectedExportFiles = TestHelper.GenerateCommaExportFiles(facilityService, accountService, fileFormatter, client); // Act // var actualExportFiles = fileService.GetExportFiles(fileFormatter, facilities); var actualExportFiles = fileService.GetExportFile(client); // Assert CollectionAssert.AreEqual(expectedExportFiles, actualExportFiles); }
public void CSVClientsProduceCSVFiles() { // Arrange var fileFormatter = new CommaFormatter(); var client = accountService.GetAllAccounts().Where(a => a.Client.FormatterType == FormatterType.CSV).FirstOrDefault().Client; var facilities = facilityService.GetAllFacilities(); var expectedExportFiles = TestHelper.GenerateCommaExportFiles(facilityService, accountService, fileFormatter, client); // Act // var actualExportFiles = fileService.GetExportFiles(fileFormatter, facilities); var actualExportFiles = fileService.GetExportFile(client); // Assert foreach (var file in actualExportFiles) { Assert.AreEqual("csv", file.FileName.Substring(file.FileName.Length - 3)); } }
public List <ExportFile> GetExportFiles(CommaFormatter fileFormatter, List <Facility> facilities, Client client) { return(new List <ExportFile>()); }
public ExportFile GetExportFile(CommaFormatter fileFormatter, List <Facility> facilities) { return(exportFile); }