private static void GenerateCsv(CsvOutputConfiguration config, Dictionary <string, int> words, string baseName) { if (!config.IsEnabled) { return; } Console.Write("Writing word list to csv..."); var csvGenerator = new CsvGenerator(); var csvData = csvGenerator.Generate(words); csvData.Save(baseName); Console.WriteLine("[Done]"); }
public void ShouldBeEmptyWhenWordsAreEmpty() { // Arrange var sut = new CsvGenerator(); var input = new Dictionary <string, int>(); // Act var actual = sut.Generate(input); // Assert var expected = "Word;Count" + Environment.NewLine; Assert.Equal(expected, actual.ToString()); }
public void ShouldContainWordsInCorrectOrder() { // Arrange var sut = new CsvGenerator(); var input = new Dictionary <string, int> { { "two", 2 }, { "three", 3 }, { "one", 1 } }; // Act var actual = sut.Generate(input); // Assert var expected = "Word;Count" + Environment.NewLine + "three;3" + Environment.NewLine + "two;2" + Environment.NewLine + "one;1" + Environment.NewLine; Assert.Equal(expected, actual.ToString()); }
static void ToCSV(Dictionary <string, string> streetsNumbers) { IFileGenerator csvGenerator = new CsvGenerator(Directory.GetCurrentDirectory(), "dachs"); csvGenerator.Generate(streetsNumbers); }
static void Main(string[] args) { PostgresDbCreator postgresDbCreator = new PostgresDbCreator(); PostgresDbSeeder postgresDbSeeder = new PostgresDbSeeder(); SQLiteDbCreator sqLiteDbCreator = new SQLiteDbCreator(); SQLiteDbSeeder sqLiteDbSeeder = new SQLiteDbSeeder(); PostgresDbExtractor postgresDbExtractor = new PostgresDbExtractor(); SQLiteDbExtractor sqLiteDbExtractor = new SQLiteDbExtractor(); CsvGenerator csvGenerator = new CsvGenerator(); HtmlGenerator htmlGenerator = new HtmlGenerator(); XmlGenerator xmlGenerator = new XmlGenerator(); CsGenerator csGenerator = new CsGenerator(); try { using (DbConnection connection = new SQLiteConnection(Configuration.SQLiteConnectionString)) { connection.Open(); var path = "D:\\sqLite_output"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); var sqLiteTables = sqLiteDbExtractor.GetTables(connection); foreach (var sqLiteTable in sqLiteTables.Where(x => x != "sqlite_sequence")) { csvGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); htmlGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); xmlGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); csGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); } } using (DbConnection connection = new NpgsqlConnection(Configuration.NpgsqlConnectionString)) { connection.Open(); var path = "D:\\pgsql_output"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); var pgsqlTables = postgresDbExtractor.GetTables(connection); foreach (var pgsqlTable in pgsqlTables) { csvGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); htmlGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); xmlGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); csGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); } } } catch (Exception e) { Console.WriteLine(e.Message); throw; } }