示例#1
0
        public void DublinCoreElementSetSyndicationExtensionConstructorTest()
        {
            DublinCoreElementSetSyndicationExtension target = new DublinCoreElementSetSyndicationExtension();

            Assert.IsNotNull(target);
            Assert.IsInstanceOfType(target, typeof(DublinCoreElementSetSyndicationExtension));
        }
示例#2
0
        public void DublinCoreElementSet_LoadTest()
        {
            DublinCoreElementSetSyndicationExtension target = new DublinCoreElementSetSyndicationExtension();             // TODO: Initialize to an appropriate value
            var nt     = new NameTable();
            var ns     = new XmlNamespaceManager(nt);
            var xpc    = new XmlParserContext(nt, ns, "US-en", XmlSpace.Default);
            var strXml = ExtensionTestUtil.GetWrappedXml(namespc, strExtXml);

            using (XmlReader reader = new XmlTextReader(strXml, XmlNodeType.Document, xpc))
            {
#if false
                //var document  = new XPathDocument(reader);
                //var nav = document.CreateNavigator();
                //nav.Select("//item");
                do
                {
                    if (!reader.Read())
                    {
                        break;
                    }
                } while (reader.NodeType != XmlNodeType.EndElement || reader.Name != "webMaster");


                bool expected = true;
                bool actual;
                actual = target.Load(reader);
                Assert.AreEqual(expected, actual);
#else
                RssFeed feed = new RssFeed();
                feed.Load(reader);
#endif
            }
        }
        /// <summary>
        /// Provides example code for the DublinCoreElementSetSyndicationExtension class.
        /// </summary>
        public static void ClassExample()
        {
            // Framework auto-discovers supported extensions based on XML namespace attributes (xmlns) defined on root of resource
            RssFeed feed = RssFeed.Create(new Uri("http://www.example.com/feed.aspx?format=rss"));

            // Extensible framework entities provide properties/methods to determine if entity is extended and predicate based seaching against available extensions
            if (feed.Channel.HasExtensions)
            {
                DublinCoreElementSetSyndicationExtension channelExtension = feed.Channel.FindExtension(DublinCoreElementSetSyndicationExtension.MatchByType) as DublinCoreElementSetSyndicationExtension;
                if (channelExtension != null)
                {
                    // Process channel extension
                }
            }

            foreach (RssItem item in feed.Channel.Items)
            {
                if (item.HasExtensions)
                {
                    DublinCoreElementSetSyndicationExtension itemExtension = item.FindExtension(DublinCoreElementSetSyndicationExtension.MatchByType) as DublinCoreElementSetSyndicationExtension;
                    if (itemExtension != null)
                    {
                        // Process extension for current item
                    }
                }
            }

            // By default the framework will automatically determine what XML namespace attributes (xmlns) to write
            // on the root of the resource based on the extensions applied to extensible parent and child entities
            using (FileStream stream = new FileStream("Feed.xml", FileMode.Create, FileAccess.Write))
            {
                feed.Save(stream);
            }
        }
示例#4
0
        public void DublinCore_TypeVocabularyByName()
        {
            var expected = DublinCoreTypeVocabularies.MovingImage;
            var actual   = DublinCoreElementSetSyndicationExtension.TypeVocabularyByName("MovingImage");

            Assert.AreEqual(expected, actual);
        }
示例#5
0
        public void DublinCore_TypeVocabularyAsString()
        {
            var    value    = DublinCoreTypeVocabularies.MovingImage;
            string expected = "MovingImage";
            string actual   = DublinCoreElementSetSyndicationExtension.TypeVocabularyAsString(value);

            Assert.AreEqual(expected, actual);
        }
示例#6
0
        public void DublinCoreElementSet_op_InequalityTest()
        {
            DublinCoreElementSetSyndicationExtension first  = CreateExtension1();
            DublinCoreElementSetSyndicationExtension second = CreateExtension2();
            bool expected = true;
            bool actual   = (first != second);

            Assert.AreEqual(expected, actual);
        }
示例#7
0
        public void DublinCoreElementSet_ToStringTest()
        {
            DublinCoreElementSetSyndicationExtension target = CreateExtension1();
            string expected = nycText;
            string actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }
示例#8
0
        public void DublinCoreElementSet_MatchByTypeTest()
        {
            ISyndicationExtension extension = CreateExtension1();
            bool expected = true;
            bool actual;

            actual = DublinCoreElementSetSyndicationExtension.MatchByType(extension);
            Assert.AreEqual(expected, actual);
        }
        public void DublinCoreElementSet_ContextTest()
        {
            DublinCoreElementSetSyndicationExtension        target   = CreateExtension1();
            DublinCoreElementSetSyndicationExtensionContext expected = CreateContext1();
            DublinCoreElementSetSyndicationExtensionContext actual   = target.Context;

            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
示例#10
0
        public void DublinCoreElementSet_GetHashCodeTest()
        {
            DublinCoreElementSetSyndicationExtension target = CreateExtension1();
            int expected = 1398804031;
            int actual;

            actual = target.GetHashCode();
            Assert.AreEqual(expected, actual);
        }
示例#11
0
        public void DublinCoreElementSet_op_GreaterThanTest()
        {
            DublinCoreElementSetSyndicationExtension first  = CreateExtension1();
            DublinCoreElementSetSyndicationExtension second = CreateExtension2();
            bool expected = false;
            bool actual   = false;

            actual = (first > second);
            Assert.AreEqual(expected, actual);
        }
示例#12
0
        public void DublinCoreElementSet_op_EqualityTest_Failure()
        {
            DublinCoreElementSetSyndicationExtension first  = CreateExtension1();
            DublinCoreElementSetSyndicationExtension second = CreateExtension2();
            bool expected = false;
            bool actual;

            actual = (first == second);
            Assert.AreEqual(expected, actual);
        }
示例#13
0
        public void DublinCoreElementSet_EqualsTest()
        {
            DublinCoreElementSetSyndicationExtension target = CreateExtension1();
            object obj      = CreateExtension1();
            bool   expected = true;
            bool   actual;

            actual = target.Equals(obj);
            Assert.AreEqual(expected, actual);
        }
示例#14
0
        public void DublinCoreElementSet_CompareToTest()
        {
            DublinCoreElementSetSyndicationExtension target = CreateExtension1();
            object obj      = CreateExtension1();
            int    expected = 0;
            int    actual;

            actual = target.CompareTo(obj);
            Assert.AreEqual(expected, actual);
        }
示例#15
0
        public void DublinCoreElementSet_WriteToTest()
        {
            DublinCoreElementSetSyndicationExtension target = CreateExtension1();

            using (var sw = new StringWriter())
                using (XmlWriter writer = new XmlTextWriter(sw))
                {
                    target.WriteTo(writer);
                    var output = sw.ToString();
                    Assert.AreEqual(nycText.Replace(Environment.NewLine, ""), output.Replace(Environment.NewLine, ""));
                }
        }
        public void DublinCoreElementSet_LoadTest()
        {
            DublinCoreElementSetSyndicationExtension target = new DublinCoreElementSetSyndicationExtension();             // TODO: Initialize to an appropriate value
            var nt     = new NameTable();
            var ns     = new XmlNamespaceManager(nt);
            var xpc    = new XmlParserContext(nt, ns, "US-en", XmlSpace.Default);
            var strXml = ExtensionTestUtil.GetWrappedXml(namespc, strExtXml);

            using (XmlReader reader = new XmlTextReader(strXml, XmlNodeType.Document, xpc))
            {
                RssFeed feed = new RssFeed();
                feed.Load(reader);
            }
        }
示例#17
0
        private DublinCoreElementSetSyndicationExtension CreateExtension2()
        {
            var dub = new DublinCoreElementSetSyndicationExtension();

            dub.Context.Contributor    = "Helper-er";
            dub.Context.Coverage       = "US";
            dub.Context.Creator        = "The Not-So-Big Guy";
            dub.Context.Date           = new DateTime(2010, 8, 1);
            dub.Context.Description    = "This kind of thing";
            dub.Context.Format         = "CDROM";
            dub.Context.Identifier     = "MYTESTCDROM-2";
            dub.Context.Language       = new CultureInfo("en-US");
            dub.Context.Publisher      = "MeMyselfI";
            dub.Context.Relation       = "MYTESTCDROM-1";
            dub.Context.Rights         = "Copyright 2010";
            dub.Context.Source         = "Nowheres, man";
            dub.Context.Subject        = "Test data (Son of)";
            dub.Context.Title          = "More Stupid test data";
            dub.Context.TypeVocabulary = DublinCoreTypeVocabularies.PhysicalObject;
            return(dub);
        }