public void RoundTripTest1() { var envelope = new SoapEnvelope { Arguments = new Dictionary<string, string> { {"filterStatement", "test"}, }, Headers = new Dictionary<string, string> { {"header1", "value"} }, Method = "SomeMethod", Namespace = "https://somenamespace.com" }; var s = new StringWriter(); using (var writer = new XmlTextWriter(s)) { //writer.Formatting = Formatting.Indented; //writer.Indentation = 2; //writer.IndentChar = ' '; envelope.WriteXml(writer); } var xml = s.ToString(); var copy = FromString(xml); Assert.AreEqual(envelope.Method, copy.Method); Assert.AreEqual(envelope.Arguments.Count, copy.Arguments.Count); Assert.AreEqual(envelope.Headers.Count, copy.Headers.Count); foreach (var header in copy.Headers.Keys) Assert.AreEqual(envelope.Headers[header], copy.Headers[header]); foreach (var argument in copy.Arguments.Keys) Assert.AreEqual(envelope.Arguments[argument], copy.Arguments[argument]); }
private SoapEnvelope FromString(string xml) { var x = new SoapEnvelope(); using (var reader = new XmlTextReader(new StringReader(xml))) { x.ReadXml(reader); } return x; }