[banshee] [Migo] Add unit tests for parsing RSS files



commit 990d74ecae78007f99a3431a155f6fbdc4ebbde2
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Sun Mar 14 14:37:33 2010 -0700

    [Migo] Add unit tests for parsing RSS files

 build/build.environment.mk                         |    2 +-
 .../Migo/Migo.Syndication/Tests/XmlTests.cs        |   28 ++++++++++++++++++++
 tests/data/beautiful-places.rss.gz                 |  Bin 0 -> 8953 bytes
 tests/data/planet-money.rss.gz                     |  Bin 0 -> 5218 bytes
 4 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/build/build.environment.mk b/build/build.environment.mk
index bce7fee..767dcbf 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -55,7 +55,7 @@ REF_LASTFM_GUI = $(LINK_GLIB) $(LINK_GTK) $(LINK_LASTFM_DEPS)
 LINK_LASTFM_GUI = -r:$(DIR_BIN)/Lastfm.Gui.dll
 LINK_LASTFM_GUI_DEPS = $(REF_LASTFM_GUI) $(LINK_LASTFM_GUI)
 
-REF_MIGO = $(LINK_HYENA_DEPS)
+REF_MIGO = $(LINK_HYENA_DEPS) $(LINK_ICSHARP_ZIP_LIB)
 LINK_MIGO = -r:$(DIR_BIN)/Migo.dll
 LINK_MIGO_DEPS = $(REF_MIGO) $(LINK_MIGO)
 
diff --git a/src/Libraries/Migo/Migo.Syndication/Tests/XmlTests.cs b/src/Libraries/Migo/Migo.Syndication/Tests/XmlTests.cs
index e89d670..95a09b0 100644
--- a/src/Libraries/Migo/Migo.Syndication/Tests/XmlTests.cs
+++ b/src/Libraries/Migo/Migo.Syndication/Tests/XmlTests.cs
@@ -29,7 +29,9 @@
 #if ENABLE_TESTS
 
 using System;
+using System.Linq;
 using NUnit.Framework;
+using ICSharpCode.SharpZipLib.GZip;
 
 using Migo.Syndication;
 
@@ -83,6 +85,32 @@ namespace Migo.Syndication.Tests
                 Assert.AreEqual (pair.To, RssParser.GetITunesDuration (pair.From));
             });
         }
+
+        [Test]
+        public void TestParseRss ()
+        {
+            foreach (string file in System.IO.Directory.GetFiles (rss_directory)) {
+                if (file.EndsWith (".rss.gz")) {
+                    Console.WriteLine ("Have rss file: {0}", file);
+                    using (var stream = System.IO.File.OpenRead (file)) {
+                        using (var gzip_stream = new GZipInputStream (stream)) {
+                            using (var txt_stream = new System.IO.StreamReader (gzip_stream)) {
+                                try {
+                                    var parser = new RssParser ("http://foo.com/";, txt_stream.ReadToEnd ());
+                                    var feed = parser.CreateFeed ();
+                                    var items = parser.GetFeedItems (feed).ToList ();
+                                    Assert.IsTrue (items.Count > 0);
+                                } catch (Exception e) {
+                                    Assert.Fail (String.Format ("Failed to parse {0}, exception:\n{1}", file, e.ToString ()));
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        private const string rss_directory = "../tests/data/";
     }
 }
 
diff --git a/tests/data/beautiful-places.rss.gz b/tests/data/beautiful-places.rss.gz
new file mode 100644
index 0000000..c169bf0
Binary files /dev/null and b/tests/data/beautiful-places.rss.gz differ
diff --git a/tests/data/planet-money.rss.gz b/tests/data/planet-money.rss.gz
new file mode 100644
index 0000000..3a55c02
Binary files /dev/null and b/tests/data/planet-money.rss.gz differ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]