Exemplo n.º 1
0
        /// <summary>
        /// Provides example code for the PheedSyndicationExtension 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)
            {
                PheedSyndicationExtension channelExtension = feed.Channel.FindExtension(PheedSyndicationExtension.MatchByType) as PheedSyndicationExtension;
                if (channelExtension != null)
                {
                    // Process channel extension
                }
            }

            foreach (RssItem item in feed.Channel.Items)
            {
                if (item.HasExtensions)
                {
                    PheedSyndicationExtension itemExtension = item.FindExtension(PheedSyndicationExtension.MatchByType) as PheedSyndicationExtension;
                    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);
            }
        }
Exemplo n.º 2
0
        public void PheedSyndicationExtensionConstructorTest()
        {
            PheedSyndicationExtension target = new PheedSyndicationExtension();

            Assert.IsNotNull(target);
            Assert.IsInstanceOfType(target, typeof(PheedSyndicationExtension));
        }
Exemplo n.º 3
0
        public void Pheed_LoadTest()
        {
            PheedSyndicationExtension target = new PheedSyndicationExtension();             // 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
            }
        }
Exemplo n.º 4
0
        private PheedSyndicationExtension CreateExtension2()
        {
            var nyc = new PheedSyndicationExtension();

            nyc.Context.Source    = new Uri("http://www.example.net");
            nyc.Context.Thumbnail = new Uri("http://www.example.net/thumbnail.png");
            return(nyc);
        }
Exemplo n.º 5
0
        public void Pheed_op_InequalityTest()
        {
            PheedSyndicationExtension first  = CreateExtension1();
            PheedSyndicationExtension second = CreateExtension2();
            bool expected = true;
            bool actual   = (first != second);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 6
0
        public void Pheed_ToStringTest()
        {
            PheedSyndicationExtension target = CreateExtension1();
            string expected = nycText;
            string actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 7
0
        public void Pheed_MatchByTypeTest()
        {
            ISyndicationExtension extension = CreateExtension1();
            bool expected = true;
            bool actual;

            actual = PheedSyndicationExtension.MatchByType(extension);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 8
0
        public void Pheed_GetHashCodeTest()
        {
            PheedSyndicationExtension target = CreateExtension1();
            int expected = -1671096665;
            int actual;

            actual = target.GetHashCode();
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 9
0
        public void Pheed_CompareToTest()
        {
            PheedSyndicationExtension target = CreateExtension1();
            object obj      = CreateExtension1();
            int    expected = 0;
            int    actual;

            actual = target.CompareTo(obj);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 10
0
        public void Pheed_op_GreaterThanTest()
        {
            PheedSyndicationExtension first  = CreateExtension1();
            PheedSyndicationExtension second = CreateExtension2();
            bool expected = false;
            bool actual   = false;

            actual = (first > second);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 11
0
        public void Pheed_op_EqualityTest_Failure()
        {
            PheedSyndicationExtension first  = CreateExtension1();
            PheedSyndicationExtension second = CreateExtension2();
            bool expected = false;
            bool actual;

            actual = (first == second);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 12
0
        public void Pheed_EqualsTest()
        {
            PheedSyndicationExtension target = CreateExtension1();
            object obj      = CreateExtension1();
            bool   expected = true;
            bool   actual;

            actual = target.Equals(obj);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 13
0
        public void Pheed_WriteToTest()
        {
            PheedSyndicationExtension 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, ""));
                }
        }
Exemplo n.º 14
0
        public void Pheed_CreateXmlTest()
        {
            var pheed = new PheedSyndicationExtension();

            pheed.Context.Source    = new Uri("http://www.example.com");
            pheed.Context.Thumbnail = new Uri("http://www.example.com/thumbnail.jpg");

            var    actual   = ExtensionTestUtil.AddExtensionToXml(pheed);
            string expected = ExtensionTestUtil.GetWrappedXml(namespc, strExtXml);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 15
0
        public void Pheed_ContextTest()
        {
            PheedSyndicationExtension        target   = CreateExtension1();
            PheedSyndicationExtensionContext expected = CreateContext1();
            PheedSyndicationExtensionContext actual;

//			target.Context = expected;
            actual = target.Context;
            var b = actual.Equals(expected);

            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemplo n.º 16
0
        public void Pheed_LoadTest()
        {
            PheedSyndicationExtension target = new PheedSyndicationExtension(); // 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);
            }
        }