Example #1
0
        public void ParseFileExtensionNotSupported()
        {
            const string fileExtension = ".unused";
            var          exception     = Assert.Throws <FileLoadException>(() => _dataProcessingFactory.ProcessDataFile(fileExtension));

            Assert.Equal(exception.Message, $"File: {fileExtension} is not supported");
        }
Example #2
0
        /// <summary>
        /// Read the data from the input files and output details to the console window
        /// </summary>
        public void ReadDataFilesAndOutputDetails()
        {
            //we will read in the files from the FeedData folder and then locate the horse information
            try
            {
                var folderPath = Path.Combine(Path.GetDirectoryName(
                                                  System.Reflection.Assembly.GetExecutingAssembly().Location), @"FeedData");

                var horses = new List <Horse>();

                var files = GetAllFilesInFolder(folderPath);
                foreach (var dataFile in files)
                {
                    //determine the type of file being handled
                    var fileProcessor = _feedDataProcessingFactory.ProcessDataFile(dataFile.Extension);

                    //read in the file data
                    var horseData = fileProcessor.ReadFile(dataFile.FullName);
                    if (horseData.Any())
                    {
                        //if we have some horses, then add them to the collection
                        horses.AddRange(horseData);
                    }
                }

                //output the horse names
                DisplayHorseNameInPriceOrder(horses);
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
            }
        }