Ejemplo n.º 1
0
 public void ParseCSV_WithEmptyPath_ThrowsException()
 {
     try
     {
         var result = _csvHelper.ParseCSVFile <WeatherData>("", null);
     }
     catch (Exception ex)
     {
         Assert.AreEqual("File path cannot be empty", ex.Message);
     }
 }
Ejemplo n.º 2
0
        public string GenerateWeatherTrendsReport(string filePath)
        {
            // Validate filepath and throw an exception if it is null or empty
            if (string.IsNullOrEmpty(filePath.Trim()))
            {
                throw new Exception("File path cannot be null or empty");
            }

            WeatherDataMap map = new WeatherDataMap();

            var weatherData = _csvHelper.ParseCSVFile <WeatherData>(filePath, map);

            var reportData = new WeatherDataViewModel
            {
                WeatherDataForYears = GetWeatherDataForYears(weatherData)
            };

            return(_jsonHelper.ConvertToJson(reportData));
        }