示例#1
0
        public void CSV_Fails_whenFileExistsButNoDataInfile()
        {
            //Arrange
            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), _configuration.GetValue <string>("AnimalCSVPathEmpty"));

            //Act
            var returnValue = _fileReaderService.ReadCSVFile <Animals>(path);

            //Assert
            Assert.Equal("0", returnValue.Count.ToString());
        }
示例#2
0
        public List <Animals> GetAnimals(string path)
        {
            List <Animals> animalsList = new List <Animals>();

            try
            {
                var animalsData = _fileReaderService.ReadCSVFile <Animals>(path);

                foreach (Animals record in animalsData)
                {
                    record.FoodPercentage = record.FoodPercentage.Replace("%", string.Empty);
                    animalsList.Add(record);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("Animal CSV file is not in correct format");
                _logger.LogError(ex.Message);
                Console.WriteLine("Animal CSV file is not in correct format");
            }

            return(animalsList);
        }