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");
        }
        public void StringConstructorShouldCreateEmptyElementWithNoNamespace()
        {
            var actual = new XmlElementAsDictionary("foo");

            actual.ToElement().Name.LocalName.ShouldEqual("foo");
            actual.ToElement().Name.Namespace.ShouldEqual(XNamespace.None);
        }
        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 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 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");
        }
        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");
        }
 public void EmptyElementCreationWithClear()
 {
     var xml = new XmlElementAsDictionary("foo");
     xml["bar"].Clear();
     var actual = xml.ToElement();
     actual.ShouldNotBeNull();
     actual.Value.ShouldEqual(string.Empty);
 }
        public void CountShouldGetReflectNumberOfElements()
        {
            var xml = new XmlElementAsDictionary("foo");
            xml["bar"].Clear();

            xml.Count.ShouldEqual(1);

            xml.ToElement().Elements().Count().ShouldEqual(1);
        }