Esempio n. 1
0
        public void XMLPropertyGet()
        {
            XElement          contact       = new XElement("contact", new XElement("phone", "925-555-0134"));
            XStreamingElement streamElement = new XStreamingElement("contact", contact.Element("phone"));

            Assert.Equal(contact.ToString(SaveOptions.None), streamElement.ToString(SaveOptions.None));
        }
Esempio n. 2
0
        public void AddWithNull()
        {
            XStreamingElement streamElement = new XStreamingElement("contact");

            streamElement.Add(null);
            Assert.Equal("<contact />", streamElement.ToString());
        }
        public void ToStringAttributeAfterText()
        {
            var el = new XStreamingElement("foo",
                                           "text",
                                           new XAttribute("bar", "baz"));

            el.ToString();
        }
        public void ToString()
        {
            var el = new XStreamingElement("foo",
                                           new XAttribute("bar", "baz"),
                                           "text");

            Assert.AreEqual("<foo bar=\"baz\">text</foo>", el.ToString());
        }
Esempio n. 5
0
                //[Variation(Priority = 0, Desc = "Constructor - XStreamingElement(XName)")]
                public void XNameConstructor()
                {
                    XStreamingElement streamElement = new XStreamingElement("contact");

                    if (!streamElement.ToString().Equals("<contact />"))
                    {
                        throw new TestFailedException("");
                    }
                }
Esempio n. 6
0
                //[Variation(Priority = 1, Desc = "Add(null)")]
                public void AddWithNull()
                {
                    XStreamingElement streamElement = new XStreamingElement("contact");

                    streamElement.Add(null);
                    if (!streamElement.ToString().Equals("<contact />"))
                    {
                        throw new TestFailedException("");
                    }
                }
Esempio n. 7
0
                //[Variation(Priority = 0, Desc = "XML Property")]
                public void XMLPropertyGet()
                {
                    XElement          contact       = new XElement("contact", new XElement("phone", "925-555-0134"));
                    XStreamingElement streamElement = new XStreamingElement("contact", contact.Element("phone"));

                    if (!streamElement.ToString(SaveOptions.None).Equals(contact.ToString(SaveOptions.None)))
                    {
                        throw new TestFailedException("");
                    }
                }
Esempio n. 8
0
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            XStreamingElement Tree = new XStreamingElement("ThongTin",
                                                           from item in TapItem("F:\\File xml ROW\\ThongTin.xml")
                                                           where (string)item.Element("Ten") == txtTen.Text || (string)item.Element("SoSao") == txtSoSao.Text || (string)item.Attribute("Phe") == Phe.Text
                                                           select item
                                                           );

            textBox11.Text = Tree.ToString();
        }
Esempio n. 9
0
        internal static void StreamingElementWithChildElementModification()
        {
            XElement source = new XElement("source", new XElement("child", "a"));
            XElement child  = source.Elements().Single();

            XElement          immediateParent = new XElement("parent", child);
            XStreamingElement deferredParent  = new XStreamingElement("parent", child); // Deferred.

            child.Value = "b";
            immediateParent.ToString(SaveOptions.DisableFormatting).WriteLine(); // <parent><child>a</child></parent>
            deferredParent.ToString(SaveOptions.DisableFormatting).WriteLine();  // <parent><child>b</child></parent>
        }
Esempio n. 10
0
        public void ToXStreamingElementTest0()
        {
            // Arrange
            IEnumerable enumerable = new int[] { 0, 1, 2, 3, 4 };

            // Act
            XStreamingElement element = enumerable.ToXStreamingElement();
            XElement          result  = XElement.Parse(element.ToString());

            // Assert
            Assert.True(result.Elements().Count() == ((IEnumerable <int>)enumerable).Count());
        }
Esempio n. 11
0
        public void ToXStreamingElementTest2()
        {
            // Arrange
            XElement elements = new XElement("root",
                                             new XElement("A", "a"),
                                             new XElement("B", "b"),
                                             new XElement("C", "c")
                                             );

            // Act
            XStreamingElement element = elements.ToXStreamingElement();
            XElement          result  = XElement.Parse(element.ToString());

            // Assert
            Assert.Equal(elements.ToString(), result.ToString());
        }
Esempio n. 12
0
        internal static void StreamingElementWithChildElements()
        {
            IEnumerable <XElement> ChildElementsFactory() =>
            Enumerable
            .Range(0, 5).Do(value => value.WriteLine())
            .Select(value => new XElement("child", value));

            XElement immediateParent = new XElement("parent", ChildElementsFactory()); // 0 1 2 3 4.

            immediateParent.ToString(SaveOptions.DisableFormatting).WriteLine();
            // <parent><child>0</child><child>1</child><child>2</child><child>3</child><child>4</child></parent>

            XStreamingElement deferredParent = new XStreamingElement("parent", ChildElementsFactory()); // Deferred.

            deferredParent.ToString(SaveOptions.DisableFormatting).WriteLine();
            // 0 1 2 3 4
            // <parent><child>0</child><child>1</child><child>2</child><child>3</child><child>4</child></parent>
        }
Esempio n. 13
0
        public void ToXStreamingElementTest1()
        {
            // Arrange
            IEnumerable enumerable = new XElement[]
            {
                new XElement("A", "a"),
                new XElement("B", "b"),
                new XElement("C", "c"),
            };

            // Act
            XStreamingElement element  = enumerable.ToXStreamingElement();
            XElement          result   = XElement.Parse(element.ToString());
            XElement          expected = new XElement("root", enumerable);

            // Assert
            Assert.Equal(expected.ToString(), result.ToString());
        }
Esempio n. 14
0
        public void XNameAndNullObjectConstructor()
        {
            XStreamingElement streamElement = new XStreamingElement("contact", null);

            Assert.Equal("<contact />", streamElement.ToString());
        }
Esempio n. 15
0
        public void XNameConstructor()
        {
            XStreamingElement streamElement = new XStreamingElement("contact");

            Assert.Equal("<contact />", streamElement.ToString());
        }