PageRenderTime 142ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/QFeedParser.Tests/KnownValueTestLoader.cs

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