Exemplo n.º 1
0
        public void TwoStringConstructorShouldCreateEmptyElementWithNamespace()
        {
            var actual = new XmlElementAsDictionary("foo", "www.test.org");

            actual.ToElement().Name.LocalName.ShouldEqual("foo");
            actual.ToElement().Name.Namespace.NamespaceName.ShouldEqual("www.test.org");
        }
Exemplo n.º 2
0
        public void StringConstructorShouldCreateEmptyElementWithNoNamespace()
        {
            var actual = new XmlElementAsDictionary("foo");

            actual.ToElement().Name.LocalName.ShouldEqual("foo");
            actual.ToElement().Name.Namespace.ShouldEqual(XNamespace.None);
        }
Exemplo n.º 3
0
        public void TwoStringConstructorWithPrefixShouldCreateEmptyElementWithPrefixedNamespace()
        {
            var actual = new XmlElementAsDictionary("a:foo", "www.test.org");

            actual.ToElement().Name.LocalName.ShouldEqual("foo");
            actual.ToElement().Name.Namespace.ShouldEqual(actual.ToElement().GetNamespaceOfPrefix("a"));
            actual.Attributes["xmlns:a"].ShouldEqual("www.test.org");
        }
        public void DefaultNamespaceAttributeValueCheck()
        {
            var xml = new XmlElementAsDictionary("foo", "www.test.org");

            xml.Attributes["bar"] = "quux";

            xml.ToElement().Attribute(xml.ToElement().GetDefaultNamespace() + "bar").Value.ShouldEqual("quux");
        }
        public void PrefixedNamespaceAttributeValueCheck()
        {
            var xml = new XmlElementAsDictionary("foo");

            xml.AddPrefixedNamespace("q", "www.test.org");
            xml.Attributes["q:bar"] = "quux";

            xml.ToElement().Attribute(xml.ToElement().GetNamespaceOfPrefix("q") + "bar").Value.ShouldEqual("quux");
        }
Exemplo n.º 6
0
        public void AttributeWithPrefixShouldHaveCorrectNamespace()
        {
            var actual = new XmlElementAsDictionary("foo");

            actual.AddPrefixedNamespace("x", "www.test.org");
            actual.Attributes["x:bar"] = "Fnord";

            var        xname = actual.ToElement().GetNamespaceOfPrefix("x") + "bar";
            XAttribute attr;

            (attr = actual.ToElement().Attribute(xname)).ShouldNotBeNull();
            attr.Value.ShouldEqual("Fnord");
        }
        public void PlainAttributeValueCheck()
        {
            var xml = new XmlElementAsDictionary("foo");

            xml.Attributes["bar"] = "quux";

            xml.ToElement().Attribute("bar").Value.ShouldEqual("quux");
        }
Exemplo n.º 8
0
        public void CountShouldGetReflectNumberOfElements()
        {
            var xml = new XmlElementAsDictionary("foo");

            xml["bar"].Clear();

            xml.Count.ShouldEqual(1);

            xml.ToElement().Elements().Count().ShouldEqual(1);
        }
Exemplo n.º 9
0
        public void EmptyElementCreationWithClear()
        {
            var xml = new XmlElementAsDictionary("foo");

            xml["bar"].Clear();
            var actual = xml.ToElement();

            actual.ShouldNotBeNull();
            actual.Value.ShouldEqual(string.Empty);
        }