Beispiel #1
0
        public void SetAttributeShouldBeSet()
        {
            var actual = new XmlElementAsDictionary("foo");

            actual.Attributes["bar"] = "Fnord";
            actual.Attributes["bar"].ShouldEqual("Fnord");
        }
Beispiel #2
0
        public void StringConstructorShouldCreateEmptyElementWithNoNamespace()
        {
            var actual = new XmlElementAsDictionary("foo");

            actual.ToElement().Name.LocalName.ShouldEqual("foo");
            actual.ToElement().Name.Namespace.ShouldEqual(XNamespace.None);
        }
Beispiel #3
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");
        }
Beispiel #4
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 PlainAttributeValueCheck()
        {
            var xml = new XmlElementAsDictionary("foo");

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

            xml.ToElement().Attribute("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");
        }
Beispiel #8
0
        public void CountShouldGetReflectNumberOfElements()
        {
            var xml = new XmlElementAsDictionary("foo");

            xml["bar"].Clear();

            xml.Count.ShouldEqual(1);

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

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

            actual.ShouldNotBeNull();
            actual.Value.ShouldEqual(string.Empty);
        }
Beispiel #10
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");
        }
        private static XmlElementAsDictionary GetResponseBodyXml(WebResponse response)
        {
            if (response == null)
            {
                return(null);
            }

            var stream = response.GetResponseStream();

            if (stream == null || !stream.CanRead)
            {
                return(null);
            }

            return(XmlElementAsDictionary.Parse(stream));
        }
Beispiel #12
0
        public void UnsetAttributeShouldBeNull()
        {
            var actual = new XmlElementAsDictionary("foo");

            actual.Attributes["bar"].ShouldBeNull();
        }
Beispiel #13
0
        public void ReadWithPrefixedNamespace()
        {
            var xml = new XmlElementAsDictionary(XElement.Parse(@"<foo xmlns:q=""www.test.org"" q:bar=""quux""/>"));

            xml.Attributes["q:bar"].ShouldEqual("quux");
        }
Beispiel #14
0
        public void ReadWithDefaultNamespace()
        {
            var xml = new XmlElementAsDictionary(XElement.Parse(@"<foo bar=""quux"" xmlns=""www.test.org""/>"));

            xml.Attributes["bar"].ShouldEqual("quux");
        }
        public void SecondDescendantIsTweetTwo()
        {
            XmlElementAsDictionary actual = ParseDescendantsUnderTest.Skip(1).First();

            actual["text"].Value.ShouldEqual("Tweet two.");
        }
        public void FirstDescendantIsTweetOne()
        {
            XmlElementAsDictionary actual = ParseDescendantsUnderTest.First();

            actual["text"].Value.ShouldEqual("Tweet one.");
        }