public void dictionary_xml_reader() { Assert.Throws<ArgumentNullException>(() => ((XmlReader)null).Dictionary()); var xml = new XDocument( new XElement("Articles", new XElement("Article", new XComment("Comment"), new XAttribute("Id", "id"), new XElement("Name", "name"), new XElement("Date", DateTime.MaxValue), new XElement("Description", new XCData("description")), new XElement("Tags", new XElement("Tag", "tag1"), new XElement("Tag", "tag2"))))); var xmlDictionary = xml.Dictionary(); IDictionary<string, object> dictionary; using (var reader = new StringReader(xml.ToString()).XmlReader(true)) { dictionary = reader.Dictionary(); Assert.True(dictionary.Keys.SequenceEqual(xmlDictionary.Keys)); } var xmlReader = new StringReader(xml.ToString()).XmlReader(true); dictionary = xmlReader.Dictionary(); Assert.False(xmlReader.Read()); Assert.True(dictionary.Keys.SequenceEqual(xmlDictionary.Keys)); }