public void ParseAndFormat(SampleFeed embeddedDocument) { // arrange var document1 = embeddedDocument.XDocument; // action var tryParseResult = Rss20FeedParser.TryParseRss20Feed(document1, out var feed); Assert.True(tryParseResult); var tryFormatResult = Rss20FeedFormatter.TryFormatRss20Feed(feed, out var document2); Assert.True(tryFormatResult); var xmlWriterSettings = new XmlWriterSettings { Indent = true }; var xmlStringBuilder1 = new StringBuilder(); var xmlStringBuilder2 = new StringBuilder(); using (var xmlWriter1 = XmlWriter.Create(xmlStringBuilder1, xmlWriterSettings)) using (var xmlWriter2 = XmlWriter.Create(xmlStringBuilder2, xmlWriterSettings)) { document1.WriteTo(xmlWriter1); document2.WriteTo(xmlWriter2); xmlWriter1.Flush(); xmlWriter2.Flush(); // assert var xmlString1 = xmlStringBuilder1.ToString(); var xmlString2 = xmlStringBuilder2.ToString(); Assert.Equal(xmlString1, xmlString2); } }
public void ParseWithoutCrashing(SampleFeed embeddedDocument) { // arrange var document = embeddedDocument.XDocument; // action // ReSharper disable once UnusedVariable var tryParseResult = Rss20FeedParser.TryParseRss20Feed(document, out var parsedFeed); // assert Assert.True(tryParseResult); }
public void DebugRssGenerators() { var sampleFeeds = SampleFeedDirectory.GetSampleFeeds(); // ReSharper disable once UnusedVariable var feedsByGenerator = sampleFeeds .Where(x => x.XDocument != null) .Select(x => { var tryParseResult = Rss20FeedParser.TryParseRss20Feed(x.XDocument, out var rss20Feed); return(feed: x, rss20Feed, tryParseResult); }) .Where(x => x.tryParseResult) .Select(x => (x.feed, generator: x.rss20Feed.Channel?.Generator)) .GroupBy(x => x.generator ?? string.Empty, x => x.feed) .ToDictionary(x => x.Key, x => x.ToList()); Debugger.Break(); // take a look at "feedsByGenerator" }
private async Task <ISyndicationItem> ReadItem(Rss20FeedReader reader) { ISyndicationItem item = null; if (_sizeOfItem == 0) { //The size of the item has not been read. ISyndicationContent content = await reader.ReadContent(); //_sizeOfItem = Encoding.UTF8.GetByteCount(content.RawContent); _sizeOfItem = 291; // content.RawContent.Length; Rss20FeedParser parser = reader.Parser as Rss20FeedParser; item = parser.CreateItem(content); } else { item = await reader.ReadItem(); } return(item); }