public void Test_BasicHelpers_GetCsvHeaderNames() { // arrange Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); DataServiceForCsvFile dataServiceForCsvFile = new DataServiceForCsvFile(this.FolderPath_CountryData); // act string[] result = BasicHelpers.GetCsvHeaderNames(Path.Combine(this.FolderPath_CountryData + "/FromGitHub/datasets/country-codes/", "country-codes.csv"));//dataServiceForCsvFile.Reader_GitHubUser_Datasets.GetCsvHeaderNames(); string headerName_first = result[0]; string headerName_last = result[result.Length - 1]; // assert Assert.IsTrue(headerName_first == "FIFA"); Assert.IsTrue(headerName_last == "EDGAR"); stopwatch.Stop(); string timeElpsed = stopwatch.Elapsed.ToString(); }
public void GenerateModelInterfaceFromCsvFile(string genInterfaceName, string fileGeneratedNameWithExt, string csvFilePath, string destinationfullDirectoryPath) { //string pathCSVFile = _DataServiceForCsvFile.Reader_GitHubUser_Datasets.FilePath_csv_countryCodes; string[] headers = BasicHelpers.GetCsvHeaderNames(csvFilePath); //Create fields string interfaceFields = string.Empty; for (int i = 0; i < headers.Length; i++) { //Filter non alphanumeric characters string filteredString_toAlphanumeric = BasicHelpers._ReplcaeNonAlphanumeric(headers[i]); //Lowercase all the string filteredString_toAlphanumeric = filteredString_toAlphanumeric.ToLowerInvariant(); //Uppercase only first letter of the string filteredString_toAlphanumeric = BasicHelpers.FirstCharToUpper(filteredString_toAlphanumeric); interfaceFields = interfaceFields + $@" string {filteredString_toAlphanumeric} {{ get; set; }}"; } string modelAutoGenTest = $@" public interface {genInterfaceName} {{ {interfaceFields} }} "; //this.PathProject_directory + System.IO.Directory.CreateDirectory(destinationfullDirectoryPath); string combinedPath = Path.Combine(destinationfullDirectoryPath, $@"{fileGeneratedNameWithExt}"); System.IO.File.WriteAllText(combinedPath, modelAutoGenTest); }