public void RssDocumentMultipleUrlTest() { foreach (string url in RssUtility.RssUrls) { rss = RssDocument.Load(new System.Uri(url)); Assert.IsTrue(rss.Channel.Items.Count > 0); } }
public void RssXmlHelperConvertToRssTest() { RssDocument rss = RssDocument.Load(RssXmlHelper.ConvertToRssXml(RssUtility.AtomXml)); Assert.IsTrue(rss.Channel.Items.Count > 0); rss = RssDocument.Load(RssXmlHelper.ConvertToRssXml(RssUtility.RdfXml)); Assert.IsTrue(rss.Channel.Items.Count > 0); }
public void RssAggregatorLoadFromUrlTest() { RssAggregator target = new RssAggregator(); string opmlUrl = RssToolkitUnitTest.Utility.RssUtility.OpmlUrl; target.Load(new System.Uri(opmlUrl)); RssDocument rss = RssDocument.Load(target.RssXml); Assert.IsTrue(rss.Channel.Items.Count > 0); }
public void Test() { var request = WebRequest.Create("http://bash.im/rss/"); var response = request.GetResponse(); var stream = response.GetResponseStream(); var rss = RssDocument.Load(stream); Assert.AreEqual("Bash.im", rss.Channel.Title); Assert.AreEqual("Цитатник Рунета", rss.Channel.Description); }
public void WriteRead_LargeObject_Ok() { var ms = new MemoryStream(); var rss = GetFullRss(); RssDocument.WriteRSS(rss, ms); ms.Position = 0; var newRss = RssDocument.Load(ms); Assert.AreEqual(rss.Channel.Description, newRss.Channel.Description); }
public void Test() { var request = WebRequest.Create("https://news.microsoft.com/feed/"); var response = request.GetResponse(); var stream = response.GetResponseStream(); var rss = RssDocument.Load(stream); Assert.Equal("Stories", rss.Channel.Title); Assert.Equal("Microsoft news, features, events, and press materials", rss.Channel.Description); }
public void RssXmlHelperToRssXmlTest() { string rssUrl = "http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml"; RssDocument rss = RssDocument.Load(new System.Uri(rssUrl)); string xml = RssXmlHelper.ToRssXml <RssDocument>(rss); Assert.IsFalse(string.IsNullOrEmpty(xml), "RssToolkit.Rss.RssXmlHelper.ToRssXml did not return the expected value."); System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); xmlDocument.LoadXml(xml); Assert.IsTrue(xmlDocument.DocumentElement.LocalName.Equals("rss", StringComparison.OrdinalIgnoreCase), "RssToolkit.Rss.RssXmlHelper.ToRssXml did not return the expected value."); Assert.IsTrue(xmlDocument.SelectNodes("/rss/channel/item").Count > 0, "RssToolkit.Rss.RssXmlHelper.ToRssXml did not return the expected value."); }
public void Read_External_Ok() { var ms = new MemoryStream(); var array = Encoding.UTF8.GetBytes(GetPartRssText()); ms.Write(array, 0, array.Length); ms.Position = 0; var rss = RssDocument.Load(ms); Assert.AreEqual("channel title", rss.Channel.Title); Assert.AreEqual("long description", rss.Channel.Description); }
public void RssAggregatorLoadTest() { RssAggregator target = new RssAggregator(); RssToolkitUnitTest.RssToolkit_Rss_RssAggregatorAccessor accessor = new RssToolkitUnitTest.RssToolkit_Rss_RssAggregatorAccessor(target); OpmlDocument opmlDocument = RssToolkitUnitTest.Utility.RssUtility.GetOpmlDocumentFromXml(); accessor.Load(opmlDocument); RssDocument rss = RssDocument.Load(target.RssXml); Assert.IsTrue(rss.Channel.Items.Count > 0); }
/// <summary> /// Binds the RSS news. /// </summary> private void BindRssNews() { string ss = ""; if (!String.IsNullOrEmpty(RssPath)) { RssDocument rssDocument = null; try { rssDocument = RssDocument.Load(new Uri(RssPath)); } catch { Response.ContentType = "text/xml"; Response.Write("<div style='text-align:center;padding:10px;color:red;' class='text'>" + RM.GetString("RSS_ERROR") + "</div>"); return; } // Create root element XmlDocument doc = new XmlDocument(); XmlNode root = doc.AppendChild(doc.CreateElement("rssData")); XmlNode node = doc.CreateElement("htmlData"); RssChannel channel = rssDocument.Channel; StringBuilder sb = new StringBuilder(); sb.AppendFormat("<div>"); sb.AppendFormat("<div style='padding-top: 3px;padding-bottom:3px;color: #444;font-size: 10pt;'><b>{0}</b></div>", channel.Title); for (int i = 0; i < channel.Items.Count && i < RssCount; i++) { sb.AppendFormat("<div style='padding-top: 3px;' class='text'><a href='{1}' target='_blank'>{0}</a></div>", channel.Items[i].Title, channel.Items[i].Link); sb.AppendFormat("<div style='color: gray;' class='text'>{0}</div>", channel.Items[i].PubDate); //sb.AppendFormat("<div style='color: black; font-family: tahoma; font-size: 12px;'>{0}</div>", channel.Items[i].Attributes["description"]); } sb.Append("</div>"); XmlNode cdata = doc.CreateCDataSection(sb.ToString()); //node.Name = "htmlData"; node.AppendChild(cdata); root.AppendChild(node); //doc.DocumentElement.AppendChild(doc.CreateCDataSection(sb.ToString())); ss += doc.InnerText; } Response.ContentType = "text/xml"; Response.Write(ss); }
public void DownloadManagerGetFeedTest() { string url = RssToolkitUnitTest.Utility.RssUtility.RssUrl; using (Stream actual = RssToolkit.Rss.DownloadManager.GetFeed(url)) { using (XmlTextReader reader = new XmlTextReader(actual)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { break; } } string outerXml = reader.ReadOuterXml(); RssDocument rss = RssDocument.Load(outerXml); Assert.IsTrue(outerXml.Length > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value."); Assert.IsTrue(rss.Channel.Items.Count > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value."); } } url = RssToolkitUnitTest.Utility.RssUtility.OpmlUrl; using (Stream actual = RssToolkit.Rss.DownloadManager.GetFeed(url)) { using (XmlTextReader reader = new XmlTextReader(actual)) { while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { break; } } string outerXml = reader.ReadOuterXml(); RssDocument rss = RssDocument.Load(outerXml); Assert.IsTrue(actual.Length > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value."); Assert.IsTrue(rss.Channel.Items.Count > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value."); } } }
internal void ReLoad(bool throwExceptionOnError) { try { LastRequested = DateTime.Now; RssDocument doc = RssDocument.Load(new Uri(Url)); Document = doc; LastSuccessfulRequest = DateTime.Now; Log.Info("Feed", "The feed {0} was successfully updated", Url); } catch (Exception ex) { Log.Error("Feed", "The feed {0} (Name:{2} Id:{3} was not successfully updated. Reason: {1}", Url, ex.Message, Name, Id); if (throwExceptionOnError) { throw; } } }
private void button1_Click(object sender, EventArgs e) { string url = urlComboBox.Text; if (url != _dataSource.Url) { try { RssDocument rss = RssDocument.Load(new System.Uri(url)); lock (_history) { AddToHistory(url); } } catch { MessageBox.Show(this, "Failed to load RSS feed for the specified URL", "RssDataSource Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } _dataSource.Url = url; DialogResult = DialogResult.OK; }
public static RssDocument GetRssDocumentFromOpmlXml() { RssDocument rss = RssDocument.Load(OpmlXml); return(rss); }
public static RssDocument GetRssDocumentFromOpmlUrl() { RssDocument rss = RssDocument.Load(new System.Uri(OpmlUrl)); return(rss); }
public void RssXmlHelperLoadRssFromOpmlUrlTest() { RssDocument rss = RssDocument.Load(new System.Uri(RssUtility.OpmlUrl)); Assert.IsTrue(rss.Channel.Items.Count > 0, "RssToolkit.Rss.RssXmlHelper.GetDocumentType did not return the expected value."); }