Exemplo n.º 1
0
        /// <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);
            }
        }
Exemplo n.º 2
0
        public void EnumDescDataStoreSaveToCsv()
        {
            IEnumDescRepository saveData = new EnumDescSaveToCsv();

            ((EnumDescSaveToCsv)saveData).FileName = @".\EnumFileSaveTest.csv";

            saveData.SaveDataEnumDescSetAsync(edc).Wait();
            Assert.IsTrue(true);
        }
Exemplo n.º 3
0
        public void EnumServiceLoadCsvToDB()
        {
            string fileName = "EnumServiceLoadCSVTest.csv";

            if (File.Exists($"Complete-{fileName}"))
            {
                System.IO.File.Move($"Complete-{fileName}", fileName);
            }
            else if (!File.Exists(fileName))
            {
                EnumDescSaveToCsv csv = new EnumDescSaveToCsv();
                csv.FileName = fileName;
                csv.SaveDataEnumDescSetAsync(_edc).Wait();
            }
            _es.SetupLoadFileToDBAsync(fileName).Wait();
            Assert.IsTrue(File.Exists($"Complete-{fileName}"));
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }