PageRenderTime 28ms CodeModel.GetById 2ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 1ms

/QFeedParser.Tests/KnownValueTestLoader.cs

#
C# | 132 lines | 120 code | 12 blank | 0 comment | 0 complexity | cff11d93a036cf5389987a822e66e19d MD5 | raw file
  1using System;
  2using System.Collections.Generic;
  3using NUnit.Framework;
  4
  5namespace QDFeedParser.Tests
  6{
  7    public static class KnownValueTestLoader
  8    {
  9        public static IList<TestCaseData> LoadAllKnownValueTestCases()
 10        {
 11            var atomCases = LoadRssKnownValueTestCases();
 12            var rssCases = LoadAtomKnownValueTestCases();
 13            foreach (var testcase in atomCases)
 14            {
 15                rssCases.Add(testcase);
 16            }
 17            return rssCases;
 18        }
 19
 20        public static IList<TestCaseData> LoadRssKnownValueTestCases()
 21        {
 22            IList<TestCaseData> returnList = new List<TestCaseData>();
 23            var feedtype = FeedType.Rss20;
 24            var feedobjecttype = typeof(Rss20Feed);
 25            IFeedKnownValueTest rssTestAaronontheweb = new RssFeedKnownValueTest
 26                                                          {
 27                                                              FeedUri =
 28                                                                  new Uri(TestFileLoader.ValidFileSysRssTestDir +
 29                                                                          "Aaronontheweb-RSS.xml"),
 30                                                              FeedObjectType = feedobjecttype,
 31                                                              FeedType = feedtype,
 32                                                              Generator = "BlogEngine.NET 1.6.1.0",
 33                                                              LastUpdated = DateTime.Parse("Mon, 14 Jun 2010 12:26:00 -1200").ToUniversalTime(),
 34                                                              Title = "Aaronontheweb",
 35                                                              Link = "http://www.aaronstannard.com/",
 36                                                              Description = ".NET Development with Social Media APIs",
 37                                                              Language = "en-GB"
 38                                                          };
 39
 40            IFeedKnownValueTest rssTestTechCrunch = new RssFeedKnownValueTest
 41                                                        {
 42                                                            FeedUri = new Uri(TestFileLoader.ValidFileSysRssTestDir + "TechCrunch-RSS.xml"),
 43                                                            FeedObjectType = feedobjecttype,
 44                                                            FeedType = feedtype,
 45                                                            Generator = "http://wordpress.com/",
 46                                                            LastUpdated = DateTime.Parse("Fri, 18 Jun 2010 01:21:15 +0000").ToUniversalTime(),
 47                                                            Title = "TechCrunch",
 48                                                            Link = "http://techcrunch.com",
 49                                                            Description = "TechCrunch is a group-edited blog that profiles the companies, products and events defining and transforming the new web.",
 50                                                            Language = "en"
 51                                                        };
 52
 53            IFeedKnownValueTest rssTestHackerNews = new RssFeedKnownValueTest
 54                                                        {
 55                                                            FeedUri = new Uri(TestFileLoader.ValidFileSysRssTestDir + "HackerNews-RSS.xml"),
 56                                                            FeedObjectType = feedobjecttype,
 57                                                            FeedType = feedtype,
 58                                                            Generator = string.Empty,
 59                                                            LastUpdated = DateTime.UtcNow,
 60                                                            Title = "Hacker News",
 61                                                            Link = "http://news.ycombinator.com/",
 62                                                            Description = "Links for the intellectually curious, ranked by readers.",
 63                                                            Language = string.Empty
 64                                                        };
 65
 66            IFeedKnownValueTest rssTestDelicious = new RssFeedKnownValueTest
 67            {
 68                FeedUri = new Uri(TestFileLoader.ValidFileSysRssTestDir + "del.icio.us-RSS.xml"),
 69                FeedObjectType = feedobjecttype,
 70                FeedType = feedtype,
 71                Generator = string.Empty,
 72                LastUpdated = DateTime.Parse("Wed, 16 Jun 2010 17:45:37 +0000").ToUniversalTime(),
 73                Title = "Delicious/Aaronontheweb",
 74                Link = "http://delicious.com/Aaronontheweb",
 75                Description = "bookmarks posted by Aaronontheweb",
 76                Language = string.Empty
 77            };
 78
 79            returnList.Add(new TestCaseData(rssTestAaronontheweb).SetName("Aaronontheweb-RSS.xml"));
 80            returnList.Add(new TestCaseData(rssTestTechCrunch).SetName("TechCrunch-RSS.xml"));
 81            returnList.Add(new TestCaseData(rssTestHackerNews).SetName("HackerNews-RSS.xml"));
 82            returnList.Add(new TestCaseData(rssTestDelicious).SetName("del.icio.us-RSS.xml"));
 83
 84            return returnList;
 85        }
 86
 87        public static IList<TestCaseData> LoadAtomKnownValueTestCases()
 88        {
 89            IList<TestCaseData> returnList = new List<TestCaseData>();
 90            QDFeedParser.FeedType feedtype = FeedType.Atom10;
 91            Type feedobjecttype = typeof(Atom10Feed);
 92
 93            IFeedKnownValueTest atomTestTed = new AtomFeedKnownValueTest
 94                                                  {
 95                                                      FeedUri = new Uri(TestFileLoader.ValidFileSysAtomTestDir + "Ted-Atom.xml"),
 96                                                      FeedObjectType = feedobjecttype,
 97                                                      FeedType = feedtype,
 98                                                      Generator = string.Empty,
 99                                                      LastUpdated = DateTime.Parse("2010-06-13T10:50:57-07:00").ToUniversalTime(),
100                                                      Title = "Ted Dziuba",
101                                                      Link = "http://teddziuba.com/",
102                                                  };
103
104            IFeedKnownValueTest atomTestGoogleNews = new AtomFeedKnownValueTest
105            {
106                FeedUri = new Uri(TestFileLoader.ValidFileSysAtomTestDir + "GoogleNews-Atom.xml"),
107                FeedObjectType = feedobjecttype,
108                FeedType = feedtype,
109                Generator = "NFE/1.0",
110                LastUpdated = DateTime.Parse("2010-06-18T03:12:56Z").ToUniversalTime(),
111                Title = "Top Stories - Google News",
112                Link = "http://news.google.com?pz=1&ned=us&hl=en",
113            };
114
115            IFeedKnownValueTest atomTestYouTube = new AtomFeedKnownValueTest
116            {
117                FeedUri = new Uri(TestFileLoader.ValidFileSysAtomTestDir + "YouTube-Atom.xml"),
118                FeedObjectType = feedobjecttype,
119                FeedType = feedtype,
120                Generator = "YouTube data API",
121                LastUpdated = DateTime.Parse("2010-05-31T22:21:27.381Z").ToUniversalTime(),
122                Title = "Uploads by smartdraw",
123                Link = "http://gdata.youtube.com/feeds/api/users/smartdraw"
124            };
125
126            returnList.Add(new TestCaseData(atomTestTed).SetName("Ted-Atom.xml"));
127            returnList.Add(new TestCaseData(atomTestGoogleNews).SetName("GoogleNews-Atom.xml"));
128            returnList.Add(new TestCaseData(atomTestYouTube).SetName("YouTube-Atom.xml"));
129            return returnList;
130        }
131    }
132}