public void ReadElementExtensions_NullSerializer_ThrowsArgumentNullException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;

            AssertExtensions.Throws <ArgumentNullException>("serializer", () => elementExtensions.ReadElementExtensions <SyndicationElementExtension>("extensionName", "extensionNamespace", (XmlObjectSerializer)null));
            AssertExtensions.Throws <ArgumentNullException>("serializer", () => elementExtensions.ReadElementExtensions <SyndicationElementExtension>("extensionName", "extensionNamespace", (XmlSerializer)null));
        }
        public void ReadElementExtensions_Invoke_ReturnsExpected()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;

            elementExtensions.Add(new ExtensionObject {
                Value = 10
            });
            elementExtensions.Add(new ExtensionObject {
                Value = 11
            });
            elementExtensions.Add(new OtherExtensionObject {
                Value = 11
            });
            elementExtensions.Add(new Inner.OtherExtensionObject {
                Value = 11
            });

            Collection <ExtensionObject> results = elementExtensions.ReadElementExtensions <ExtensionObject>("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests");

            Assert.Equal(2, results.Count);
            Assert.Equal(10, results[0].Value);
            Assert.Equal(11, results[1].Value);

            results = elementExtensions.ReadElementExtensions <ExtensionObject>("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests", new DataContractSerializer(typeof(ExtensionObject)));
            Assert.Equal(2, results.Count);
            Assert.Equal(10, results[0].Value);
            Assert.Equal(11, results[1].Value);

            results = elementExtensions.ReadElementExtensions <ExtensionObject>("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests", new XmlSerializer(typeof(ExtensionObject)));
            Assert.Equal(2, results.Count);
            Assert.Equal(10, results[0].Value);
            Assert.Equal(11, results[1].Value);
        }
        public void ReadElementExtensions_EmptyExtensionName_ThrowsArgumentException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;

            AssertExtensions.Throws <ArgumentException>(null, () => elementExtensions.ReadElementExtensions <SyndicationElementExtension>("", "extensionNamespace"));
            AssertExtensions.Throws <ArgumentException>(null, () => elementExtensions.ReadElementExtensions <SyndicationElementExtension>("", "extensionNamespace", new DataContractSerializer(typeof(ExtensionObject))));
            AssertExtensions.Throws <ArgumentException>(null, () => elementExtensions.ReadElementExtensions <SyndicationElementExtension>("", "extensionNamespace", new XmlSerializer(typeof(ExtensionObject))));
        }
        public void ReadElementExtensions_Empty_ReturnsEmpty()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;

            Assert.Empty(elementExtensions.ReadElementExtensions <ExtensionObject>("ExtensionName", null));
            Assert.Empty(elementExtensions.ReadElementExtensions <ExtensionObject>("ExtensionName", null, new DataContractSerializer(typeof(ExtensionObject))));
            Assert.Empty(elementExtensions.ReadElementExtensions <ExtensionObject>("ExtensionName", null, new XmlSerializer(typeof(ExtensionObject))));
        }
        public void ReadElementExtensions_NoSuchObject_ReturnsEmpty(string name, string ns)
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;

            elementExtensions.Add(new ExtensionObject {
                Value = 10
            });
            elementExtensions.Add(new ExtensionObject {
                Value = 11
            });

            Assert.Empty(elementExtensions.ReadElementExtensions <ExtensionObject>(name, ns));
            Assert.Empty(elementExtensions.ReadElementExtensions <ExtensionObject>(name, ns, new DataContractSerializer(typeof(ExtensionObject))));
            Assert.Empty(elementExtensions.ReadElementExtensions <ExtensionObject>(name, ns, new XmlSerializer(typeof(ExtensionObject))));
        }