public void FromXmlTest() { /* * Assume: ToXml(string) is correct. */ var authResponse = new AuthResponse(); var xml = XElement.Parse(File.ReadAllText(Data.AuthResponseXml)).Elements().ToArray(); // Validate null argument. Assert.Throws <ArgumentNullException>("element", () => authResponse.FromXml(null)); // XML must be same after loading and deserializing it. foreach (var element in xml) { authResponse.FromXml(element); Assert.True(XNode.DeepEquals(element, authResponse.ToXml("AuthRes"))); } }