Esempio n. 1
0
        public void CreatesArrayAtRoot()
        {
            var media = new XmlMedia();

            media.Array("root", "key");

            Assert.Equal(
                "<root />",
                media.Content().ToString()
                );
        }
Esempio n. 2
0
        public void BuildsBlockInBlock()
        {
            var media = new XmlMedia();

            media.Block("root")
            .Block("contents");
            Assert.Equal(
                "<root><contents /></root>",
                media.Content().ToString(SaveOptions.DisableFormatting)
                );
        }
Esempio n. 3
0
        public void WritesArray()
        {
            var media = new XmlMedia();

            new BxArray("ItemArray", "Item", new ManyOf <string>("Entry"))
            .Print(media);

            Assert.Equal(
                "<ItemArray><Item>Entry</Item></ItemArray>",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }
Esempio n. 4
0
        public void DoesntPrintIfConditionNotMatched()
        {
            var media = new XmlMedia().Block("root");

            new BxConditional(() => false,
                              () => new BxProp("Matched", "true")
                              ).Print(media);
            Assert.Equal(
                "<root />",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }
Esempio n. 5
0
        public void WritesBlockName()
        {
            var media = new XmlMedia();

            new BxBlock("mein-block", new BxProp("stockwerk", "16"))
            .Print(media);

            Assert.Equal(
                "<mein-block><stockwerk>16</stockwerk></mein-block>",
                media.Content().ToString(SaveOptions.DisableFormatting)
                );
        }
Esempio n. 6
0
        public void PrintsProp()
        {
            var media = new XmlMedia().Block("root");

            new BxProp("Key", "Value")
            .Print(media);

            Assert.Equal(
                "<root><Key>Value</Key></root>",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }
Esempio n. 7
0
        public void CreatesPropertyInBlock()
        {
            var media = new XmlMedia();

            media.Block("root")
            .Prop("key");

            Assert.Equal(
                "1",
                new XMLCursor(media.Content()).Values("count(/root/key)")[0]
                );
        }
Esempio n. 8
0
        public void PrintsIfConditionMatched()
        {
            var media = new XmlMedia().Block("root");

            new BxConditional(() => true,
                              () => new BxProp("Matched", "true")
                              ).Print(media);
            Assert.Equal(
                "<root><Matched>true</Matched></root>",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }
Esempio n. 9
0
        public void PutsValueToProp()
        {
            var media = new XmlMedia();

            media.Block("root")
            .Prop("key")
            .Put("lock");

            Assert.Equal(
                "lock",
                new XMLCursor(media.Content()).Values("/root/key/text()")[0]
                );
        }
Esempio n. 10
0
        public void CreatesBlockInRoot()
        {
            var media = new XmlMedia();

            media.Block("root")
            .Prop("key")
            .Put("value");

            Assert.Contains(
                "value",
                new XMLCursor(media.Content()).Values("/root/key/text()")
                );
        }
Esempio n. 11
0
        public void PutsValueToArray()
        {
            var media = new XmlMedia();

            media
            .Array("items", "item")
            .Put("ei");

            Assert.Contains(
                "ei",
                new XMLCursor(media.Content()).Values("/items/item/text()")[0]
                );
        }
Esempio n. 12
0
        public void CreatesArrayInArray()
        {
            var media = new XmlMedia();

            media
            .Array("keys", "key")
            .Array("subarray", "subkey");

            Assert.Equal(
                "<keys><subarray /></keys>",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }
Esempio n. 13
0
        public void CreatesArrayInBlock()
        {
            var media = new XmlMedia();

            media
            .Block("root")
            .Array("keys", "key");

            Assert.Equal(
                "<root><keys /></root>",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }
Esempio n. 14
0
        public void WritesBlockArrayUnnamed()
        {
            var media = new XmlMedia();

            new BxBlockArray("H-Blockx", "H-Item",
                             new BxBlock(new BxProp("move", "ya")),
                             new BxBlock(new BxProp("move-move", "ya"))
                             ).Print(media);

            Assert.Equal(
                "<H-Blockx><H-Item><move>ya</move></H-Item><H-Item><move-move>ya</move-move></H-Item></H-Blockx>",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }
Esempio n. 15
0
        public void CreatesBlockInProp()
        {
            var media = new XmlMedia();

            media.Block("root")
            .Prop("my-block")
            .Block("contents");

            Assert.Contains(
                "1",
                new XMLCursor(media.Content())
                .Values("count(/root/my-block/contents)")
                );
        }
Esempio n. 16
0
        public void CreatesBlockInArray()
        {
            var media = new XmlMedia();

            media.Array("array", "item")
            .Block("item")
            .Prop("prop")
            .Put("eller");

            Assert.Equal(
                "<array><item><prop>eller</prop></item></array>",
                media.Content().ToString(SaveOptions.DisableFormatting)
                );
        }
Esempio n. 17
0
        public void PrintsBrix()
        {
            var media = new XmlMedia().Block("root");

            new BxChain(
                new BxProp("firstname", "John"),
                new BxProp("lastname", "Malkovich")
                )
            .Print(media);

            Assert.Equal(
                "<root><firstname>John</firstname><lastname>Malkovich</lastname></root>",
                media.Content().ToString(SaveOptions.DisableFormatting)
                );
        }
Esempio n. 18
0
        public void WritesProps()
        {
            var media = new XmlMedia().Block("map");

            new BxMap(
                new MapOf(
                    "firstname", "Förster",
                    "lastname", "Laster"
                    )
                ).Print(media);

            Assert.Equal(
                "<map><firstname>Förster</firstname><lastname>Laster</lastname></map>",
                media.Content().ToString(System.Xml.Linq.SaveOptions.DisableFormatting)
                );
        }