Пример #1
0
        public void ReadXmlForExtractorPrecedence()
        {
            var xml = "<Extractors>"
                      + $"<san:Properties precedence='schemaOnly' xmlns:s0='urn' xmlns:san='{SchemaAnnotation.NAMESPACE}'>"
                      + "<s0:Property1 mode='clear'/>"
                      + "</san:Properties>"
                      + "</Extractors>";

            using (var reader = XmlReader.Create(new StringReader(xml)))
            {
                var sut = new PropertyExtractorCollectionSerializerSurrogate(new PropertyExtractorCollection());
                sut.ReadXml(reader);
                sut.Precedence.Should().Be(ExtractorPrecedence.SchemaOnly);
            }
        }
Пример #2
0
        public void WriteXmlForExtractorPrecedence()
        {
            var xml = $"<s0:Properties precedence=\"pipelineOnly\" xmlns:s0=\"{SchemaAnnotation.NAMESPACE}\" xmlns:s1=\"urn\">"
                      + "<s1:Property1 xpath=\"*/some-node\" />"
                      + "</s0:Properties>";

            var builder = new StringBuilder();

            using (var writer = XmlWriter.Create(builder, new XmlWriterSettings {
                OmitXmlDeclaration = true
            }))
            {
                var sut = new PropertyExtractorCollectionSerializerSurrogate(
                    new PropertyExtractorCollection(
                        ExtractorPrecedence.PipelineOnly,
                        new XPathExtractor(new XmlQualifiedName("Property1", "urn"), "*/some-node")));
                sut.WriteXml(writer !);
            }

            builder.ToString().Should().Be(xml);
        }