static IEnumerable<Transaction> ReadAllTransactionsFromDirectory(string directory) { var dataProviders = new ITransactionProvider[] { new BoACreditCsvDataProvider(), new BoADebitCsvDataProvider(), new ChaseCreditCsvDataProvider() }; var transactions = new List<Transaction>(); var fileUniqueness = new FileContentUniqueness(); foreach (var file in Directory.EnumerateFiles(directory, "*.csv")) { var fileContent = File.ReadAllText(file); if (!fileUniqueness.IsUnique(fileContent)) { throw new Exception($"{file} has same content as some other file"); } var dataProvider = dataProviders.First(provider => provider.FormatSupported(fileContent)); transactions.AddRange(dataProvider.GetTransactions(fileContent)); } return transactions; }