<p>Is it possible for <code>SelectNodes()</code> called on an <code>XmlDocument</code> to return null?</p>

<p>My predicament is that I am trying to reach 100% unit test code coverage; ReSharper tells me that I need to guard against a null return from the <code>SelectNodes()</code> method, but I can see no way that an XmlDocument can return null (and therefore, no way to test my guard clause and reach 100% unit test coverage!)</p>

[{'answer_id': 57532, 'author': 'Jeremy McGee', 'author_id': 3546, 'author_profile': 'https://Stackoverflow.com/users/3546', 'pm_score': 3, 'selected': True, 'text': '<p>Is it necessary to reach 100% code coverage? Indeed, is it even possible under normal (i.e. controllable, testable) circumstances? </p>\n\n<p>We often find that using "syntactic sugar" constructions like the <code>using {}</code> block, there are "hidden" code paths created (most likely <code>finally {}</code> or <code>catch {}</code> blocks) that can\'t be exercised unless some environmental condition (like a broken socket or broken disk) gets in the way.</p>\n'}, {'answer_id': 57533, 'author': 'Jesse C. Slicer', 'author_id': 3312, 'author_profile': 'https://Stackoverflow.com/users/3312', 'pm_score': 3, 'selected': False, 'text': "<p>Looking at Reflector, the SelectNodes() method on XmlDocument's base class, XmlNode, can return null if its attempt to create a navigator returns null.  CreateNavigator() is pretty complex and will indeed return null under a few circumstances.  Those circumstances appear to be around a malformed XML document - so there's your test case for failure of SelectNodes().</p>\n"}, {'answer_id': 57554, 'author': 'rpetrich', 'author_id': 4007, 'author_profile': 'https://Stackoverflow.com/users/4007', 'pm_score': 2, 'selected': False, 'text': "<p>If you are calling SelectNodes on the XmlDocument itself and it really is an XmlDocument and not a derived class than SelectNodes won't return null.</p>\n\n<p>If you create a descendant class and override the CreateNavigator(XmlNode) method then SelectNodes could return null.</p>\n\n<p>Similarly, if you call SelectNodes on an EntityReference, DocumentType or XmlDeclaration node, you'll get null as well</p>\n\n<p>In short, for 100% coverage on an XmlDocument or XmlNode you didn't just create, you have to test for null.</p>\n"}]
['https://Stackoverflow.com/questions/57518', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5975/']