Example #1
0
        public void InputXmlReaderIfMovedToContentWillBeHandled()
        {
            var inputXmlReader = XmlReader.Create(new StringReader("<payload>dummy</payload>"));

            // move to content before XmlTranslatorStream initialization to let it workaround the issue
            inputXmlReader.MoveToContent();
            var stream = new XmlTranslatorStream(inputXmlReader, new[] { new XmlNamespaceTranslation {
                                                                             MatchingPatternString = string.Empty, ReplacementPattern = "urn:ns"
                                                                         } });

            stream.ReadToEnd().Should().Be("<payload xmlns=\"urn:ns\">dummy</payload>");
        }
Example #2
0
        public void InputXmlReaderCannotBeMovedToContent()
        {
            var inputXmlReader = XmlReader.Create(new StringReader("<payload>dummy</payload>"));
            var stream         = new XmlTranslatorStream(inputXmlReader, new[] { new XmlNamespaceTranslation {
                                                                                     MatchingPatternString = string.Empty, ReplacementPattern = "urn:ns"
                                                                                 } });

            // move to content after XmlTranslatorStream initialization to trick it
            inputXmlReader.MoveToContent();
            Invoking(() => stream.ReadToEnd())
            .Should().Throw <InvalidOperationException>()
            .WithMessage("There was no XML start tag open.");
        }