public void XML_Fails_whenFileExistsButNoDataInfile() { //Arrange string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), _configuration.GetValue <string>("ZooContentPathEmpty")); //Act var returnValue = _fileReaderService.ReadXMLFile(path); //Assert Assert.Null(returnValue); }
public List <ZooContent> GetZooContent(string path) { List <ZooContent> zooContent = new List <ZooContent>(); try { var zooData = _fileReaderService.ReadXMLFile(path); if (zooData == null) { return(null); } foreach (var animal in zooData) { foreach (var item in animal.Elements()) { var zoo = new ZooContent { Type = item.Name.LocalName, Name = item.FirstAttribute.Value, Weight = decimal.Parse(item.LastAttribute.Value, CultureInfo.InvariantCulture) }; zooContent.Add(zoo); } } } catch (Exception ex) { _logger.LogError("Zoo content file is not in correct format"); _logger.LogError(ex.Message); Console.WriteLine("Zoo content file is not in correct format"); } return(zooContent); }