Пример #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));
        }
Пример #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());
        }
Пример #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("");
                    }
                }
Пример #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("");
                    }
                }
Пример #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("");
                    }
                }
Пример #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();
        }
Пример #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>
        }
Пример #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());
        }
Пример #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());
        }
Пример #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>
        }
Пример #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());
        }
Пример #14
0
        public void XNameAndNullObjectConstructor()
        {
            XStreamingElement streamElement = new XStreamingElement("contact", null);

            Assert.Equal("<contact />", streamElement.ToString());
        }
Пример #15
0
        public void XNameConstructor()
        {
            XStreamingElement streamElement = new XStreamingElement("contact");

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