public void ConvertXMLToCategoryObject() { XMLToObjectConvertor convertor = new XMLToObjectConvertor(); XDocument xDoc = XDocument.Parse(_categoryXml); List <category> categories = new List <category>(); foreach (var xmlCategory in xDoc.Descendants("category")) { categories.Add(convertor.Deserialize <category>(xmlCategory.ToString())); } Assert.AreEqual(categories.Count, 1); Assert.AreEqual(categories[0].name, "hats"); }
public void ConvertXMLToImageList() { XMLToObjectConvertor convertor = new XMLToObjectConvertor(); XDocument xDoc = XDocument.Parse(_imageXml); List <image> images = new List <image>(); foreach (var xmlImage in xDoc.Descendants("image")) { images.Add(convertor.Deserialize <image>(xmlImage.ToString())); } Assert.AreEqual(images.Count, 2); Assert.AreEqual(images[0].id, "5if"); Assert.AreEqual(images[0].url, "http://image.jpg"); Assert.AreEqual(images[0].source_url, "http://thecatapi.com/?id=5if"); Assert.AreEqual(images[1].id, "3if"); Assert.AreEqual(images[1].url, "http://image2.jpg"); Assert.AreEqual(images[1].source_url, "http://thecatapi.com/?id=3if"); }