/// <summary> /// Used to setup the initial load of EnumSet Descriptions from a csv file and will store into the Database /// </summary> /// <param name="filePath"> /// The Filename used to load the csv file from /// </param> public async Task SetupLoadFileToDBAsync(string filePath) { //Grab the Setup Enum File var csv = new EnumDescSaveToCsv { FileName = filePath }; _enumSetEndpoint.DataStore = new EnumDescSaveToSqlServer(); bool fileExists = false; //Load from the file if it Exists if (await csv.DataExistsAsync()) { fileExists = true; await _enumSetEndpoint.DataStore.SaveDataEnumDescSetAsync(await csv.GetDataEnumDescSetAsync()); } else { await BuildEnumDescCollectionAsync(); //Build the List from the API and save it } //Rename the file if (fileExists) { //Commented out Temporarily, will uncomment with final build //File.Delete(filePath); //string[] pathParts = filePath.Split('\\'); //string newFilePath = filePath.Replace(pathParts[pathParts.Length - 1], $"Complete-{pathParts[pathParts.Length - 1]}"); //System.IO.File.Move(filePath, newFilePath); } }
public void EnumDescDataStoreGetFromCsv() { IEnumDescRepository saveData = new EnumDescSaveToCsv(); ((EnumDescSaveToCsv)saveData).FileName = @".\EnumFileGetTest.csv"; saveData.SaveDataEnumDescSetAsync(edc).Wait(); EnumDescCollection edc2 = saveData.GetDataEnumDescSetAsync().Result; Assert.IsTrue(edc2.Count == edc.Count); bool pass = true; foreach (EnumDescDataStoreModel enumDesc in edc2) { if (!edc.Exists(x => x.SetId == enumDesc.SetId && x.MemberId == enumDesc.MemberId)) { pass = false; } } Assert.IsTrue(pass); }
public void EnumSetEndPointRunAsync() { IEnumDescRepository csv = new EnumDescSaveToCsv(); ((EnumDescSaveToCsv)csv).FileName = @".\EnumSetFileSaveTest.csv"; _enumSetEndPoint.DataStore = csv; _enumSetEndPoint.RunAsync($"https://{ApiRequest.HttpHost}/{_enumSetEndPoint.ApiEndpoint}").Wait(); _enumSetEndPoint.SaveDataAsync(); EnumDescCollection edc = csv.GetDataEnumDescSetAsync().Result; bool hasPassed = true; foreach (EnumDescDataStoreModel dm in edc) { if (!_edc.Exists(x => x.SetId == dm.SetId && x.MemberId == dm.MemberId)) { hasPassed = false; break; } } Assert.IsTrue(hasPassed); }