Ejemplo n.º 1
0
        public void TestRemoveDataElements()
        {
            HElement element1 = new HElement("div",
                                             new HAttribute("data-value1", "value1"),
                                             new HAttribute("data-value2", "value2"),
                                             new HAttribute("data-value3", "value3")
                                             );
            HElement element2 = new HElement("div",
                                             new HAttribute("data-value2", "value2"),
                                             new HAttribute("data-value3", "value3"),
                                             new HAttribute("data-value4", "value4")
                                             );

            var elements = new HElement[] { element1, null, element2 };

            elements.RemoveData("value1", "value4");
            Assert.Equal(new String[] { "data-value2", "data-value3", "data-value2", "data-value3" }, elements.Where(e => e != null).SelectMany(e => e.Attributes()).Select(a => a.Name).ToArray());

            elements.RemoveData();

            Assert.Equal(new String[] { }, elements.Where(e => e != null).SelectMany(e => e.Attributes()).Select(a => a.Name).ToArray());

            elements = null;
            elements.RemoveData();
        }
Ejemplo n.º 2
0
        public void TestRemoveDataElement()
        {
            HElement element = new HElement("div",
                                            new HAttribute("data-value1", "value1"),
                                            new HAttribute("data-value2", "value2"),
                                            new HAttribute("data-value3", "value3")
                                            );

            element = element.RemoveData("value1", "value4");

            Assert.Equal(new String[] { "data-value2", "data-value3" }, element.Attributes().Select(a => a.Name).ToArray());

            element = element.RemoveData();

            Assert.Equal(new String[] { }, element.Attributes().Select(a => a.Name).ToArray());

            element = null;
            element = element.RemoveData();
            Assert.Null(element);
        }