Ejemplo n.º 1
0
        public void DecodeNestedEnvelopeWithMixedNamespaceWithParts()
        {
            var envelope = $"<s0:LevelOne xmlns:s0=\"{NS}:1\">" + (
                $"<s0:LevelTwo xmlns:s0=\"{NS}:2\">" + (
                    $"<s0:Parts xmlns:s0=\"{NS}:3\">" + (
                        "<part-one></part-one>" +
                        "<part-two></part-two>" +
                        "<part-six></part-six>") +
                    "</s0:Parts>") +
                "</s0:LevelTwo>") +
                           "</s0:LevelOne>";

            var bodyXPath = $"/*[local-name()='LevelOne' and namespace-uri()='{NS}:1']"
                            + $"/*[local-name()='LevelTwo' and namespace-uri()='{NS}:2']"
                            + $"/*[local-name()='Parts' and namespace-uri()='{NS}:3']";

            using (var stringReader = new StringReader(envelope))
                using (var xmlReader = XmlReader.Create(stringReader))
                    using (var envelopeMutatorStream = new XmlEnvelopeDecodingStream(xmlReader, bodyXPath))
                    {
                        var result = XmlReader.Create(envelopeMutatorStream);
                        result.MoveToContent();
                        result.ReadOuterXml().Should().Be(
                            $"<s0:LevelOne xmlns:s0=\"{NS}:1\">" + (
                                $"<s0:LevelTwo xmlns:s0=\"{NS}:2\">" + (
                                    $"<s0:Parts xmlns:s0=\"{NS}:3\">" + (
                                        "<part-one></part-one>" +
                                        "<part-two></part-two>" +
                                        "<part-six></part-six>") +
                                    "</s0:Parts>") +
                                "</s0:LevelTwo>") +
                            "</s0:LevelOne>");
                    }
        }
Ejemplo n.º 2
0
        public void DecodeRootedEnvelopeWithoutParts(string envelope)
        {
            var bodyXPath = $"/*[local-name()='Envelope' and namespace-uri()='{NS}']";

            using (var stringReader = new StringReader(envelope))
                using (var xmlReader = XmlReader.Create(stringReader))
                    using (var envelopeMutatorStream = new XmlEnvelopeDecodingStream(xmlReader, bodyXPath))
                    {
                        var result = XmlReader.Create(envelopeMutatorStream);
                        result.MoveToContent();
                        result.ReadOuterXml().Should().Be($"<s0:Envelope xmlns:s0=\"{NS}\"></s0:Envelope>");
                    }
        }