Beispiel #1
0
        public void ModifiesContent()
        {
            var mem = new RamMnemonic();

            mem.Contents()
            .UpdateXml(
                "xml-xocks",
                new XMLCursor(
                    new InputOf("<root><item>A</item></root>")
                    ).AsNode()
                );

            var xoc = new MemorizedXocument("xml-xocks", mem);

            xoc.Modify(
                new Directives()
                .Xpath("//item")
                .Set("B")
                );

            Assert.Contains(
                "B",
                xoc.Values("//item/text()")
                );
        }
Beispiel #2
0
        public IXocument Xocument(string name)
        {
            IXocument result;

            if (name.Equals("_guts.xml"))
            {
                Directives patch = GutsDirectives();
                result = new ReadOnlyXocument(
                    new XMLCursor(new Xambler(patch).Dom())
                    );
            }
            else
            {
                result = new MemorizedXocument($"{this.name.AsString()}/{name}", this.memory);
            }
            return(result);
        }
Beispiel #3
0
        public void FindsNodes()
        {
            var mem = new RamMnemonic();

            mem.Contents()
            .UpdateXml(
                "xml-xocks",
                new XMLCursor(
                    new InputOf("<root><item>A</item><item>B</item></root>")
                    ).AsNode()
                );

            var xoc = new MemorizedXocument("xml-xocks", mem);

            Assert.Equal(
                1,
                xoc.Nodes("//item[text() = 'A']").Count
                );
        }
Beispiel #4
0
        public void HasNodeContent()
        {
            var mem = new RamMnemonic();

            mem.Contents()
            .UpdateXml(
                "xml-xocks",
                new XMLCursor(
                    new InputOf("<root><item>A</item><item>B</item></root>")
                    ).AsNode()
                );

            var xoc = new MemorizedXocument("xml-xocks", mem);

            Assert.Equal(
                "A",
                xoc.Nodes("//item")[0].Values("text()")[0]
                );
        }