Exemplo n.º 1
0
        public void CopiesComplexContent()
        {
            var dom     = new XDocument();
            var content =
                new TextOf(
                    "<?xml version=\"1.0\" encoding=\"utf-16\"?>"
                    + "<?some-pi test?>"
                    + "<target id=\"BBA3CBB0-00F0-43DD-9F74-87C53D35270C\" name=\"j1046rfa_11\">"
                    + "<body><accessibility><readonly>false</readonly><reason /></accessibility><type>default</type><spatials><cartesian machine=\"BEFC5DE8-C579-44A6-ACDF-65293C39C87F\"><translation x=\"-4150.784755\" y=\"-1819.545936\" z=\"955.4282165\" /><rotation rx=\"-2.949491294\" ry=\"-0.8920227643\" rz=\"-3.120333533\" /><configuration><joints><joint name=\"j1\" state=\"irrelevant\"><turn hasvalue=\"true\">0</turn></joint><joint name=\"j2\" state=\"irrelevant\"><turn hasvalue=\"false\">0</turn></joint><joint name=\"j3\" state=\"negative\"><turn hasvalue=\"false\">0</turn></joint><joint name =\"j4\" state=\"irrelevant\"><turn hasvalue=\"true\">0</turn></joint><joint name=\"j5\" state=\"positive\"><turn hasvalue=\"false\">0</turn></joint><joint name=\"j6\" state=\"irrelevant\"><turn hasvalue=\"true\">0</turn></joint></joints><overhead>negative</overhead></configuration></cartesian><axial machine=\"F399FDD7-B9FF-4D5F-8A65-C5EC35D306BE\"><axes><axis name=\"j1\">-4871</axis></axes></axial></spatials><parameters><motiontype>ptp</motiontype><speed>70</speed><acceleration>100</acceleration><zone>C_DIS</zone><referenceframe>b4</referenceframe><toolframe>t2</toolframe><storagetype>local</storagetype><processtype /></parameters><postolpcommands /></body><foot /></target>"
                    );
            var xml = XDocument.Parse(content.AsString());

            new Xambler(
                new Joined <IDirective>(
                    new ManyOf <IDirective>(
                        new AddDirective("target")
                        ),
                    new CopyOfDirective(xml.Root.Element("body"))
                    )
                ).Apply(dom);

            var nav = dom.CreateNavigator();

            Assert.True(
                nav.SelectSingleNode("/target/body/accessibility/readonly").Value == "false"
                );
        }
Exemplo n.º 2
0
        public void PassLegalText()
        {
            var txt = new TextOf("Well formed text");

            Assert.Equal(
                txt.AsString(),
                new TextNotIllegal(txt).AsString());
        }
Exemplo n.º 3
0
        public void WorksWithEmptySpacesAfterNodeEnding()
        {
            var dom     = new XDocument();
            var content =
                new TextOf("<state><item>success</item>   </state>");
            var xml = XDocument.Parse(content.AsString());

            new Xambler(
                new Joined <IDirective>(
                    new ManyOf <IDirective>(
                        new AddDirective("root")
                        ),
                    new CopyOfDirective(xml.FirstNode)
                    )
                ).Apply(dom);

            var nav = dom.CreateNavigator();

            Assert.Equal(
                "success",
                nav.SelectSingleNode("/root/state/item").Value
                );
        }