public void Text_Fails_whenFileExistsButNoDataInfile() { //Arrange string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), _configuration.GetValue <string>("PriceTextPathEmpty")); //Act var returnValue = _fileReaderService.ReadTextFile(path); //Assert Assert.Equal("0", returnValue.Count.ToString()); }
public List <Price> GetPrice(string path) { List <Price> priceList = new List <Price>(); try { _logger.LogInformation("GetPrice method start"); var pricedata = _fileReaderService.ReadTextFile(path); foreach (var prices in pricedata) { var rate = prices.ToString().Split('='); var price = new Price { FoodType = rate[0], Rate = decimal.Parse(rate[1], CultureInfo.InvariantCulture) }; priceList.Add(price); } } catch (Exception ex) { _logger.LogError("Price text file is not in correct format"); _logger.LogError(ex.Message); Console.WriteLine("Price text file is not in correct format"); } _logger.LogInformation("GetPrice method exit"); return(priceList); }