[banshee] [Banshee.IO] Add unit tests, make them pass



commit a4da5bca6fabedda6f2f042990489fa741767f05
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Mar 19 12:37:23 2010 -0700

    [Banshee.IO] Add unit tests, make them pass
    
    Tests are from the GIO tests, but now are run for all providers (system,
    unix, and if built, GIO).  The tests were failing for System and Unix
    providers for a few things, likely causing bgo#613292

 src/Backends/Banshee.Unix/Banshee.IO.Unix/File.cs  |    2 +-
 src/Core/Banshee.Core/Banshee.IO/Directory.cs      |   54 ++--
 src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs      |    2 +
 src/Core/Banshee.Core/Banshee.IO/Provider.cs       |   11 +-
 src/Core/Banshee.Core/Banshee.IO/Tests.cs          |  321 ++++++++++++++++++++
 src/Core/Banshee.Core/Makefile.am                  |    1 +
 .../Banshee.Metadata/Tests/TaglibReadWriteTests.cs |  142 ++++-----
 src/Libraries/Hyena/Makefile.am                    |    6 -
 src/Libraries/Lastfm/Makefile.am                   |    2 +-
 9 files changed, 430 insertions(+), 111 deletions(-)
---
diff --git a/src/Backends/Banshee.Unix/Banshee.IO.Unix/File.cs b/src/Backends/Banshee.Unix/Banshee.IO.Unix/File.cs
index da64d13..2b19c25 100644
--- a/src/Backends/Banshee.Unix/Banshee.IO.Unix/File.cs
+++ b/src/Backends/Banshee.Unix/Banshee.IO.Unix/File.cs
@@ -99,7 +99,7 @@ namespace Banshee.IO.Unix
         {
             return overwrite
                 ? new UnixFileInfo (uri.LocalPath).Open (FileMode.Create, FileAccess.ReadWrite, FilePermissions.DEFFILEMODE)
-                : new UnixFileInfo (uri.LocalPath).OpenWrite ();
+                : new UnixFileInfo (uri.LocalPath).Create ();
         }
 
         public long GetSize (SafeUri uri)
diff --git a/src/Core/Banshee.Core/Banshee.IO/Directory.cs b/src/Core/Banshee.Core/Banshee.IO/Directory.cs
index ee34bcb..cbd12fd 100644
--- a/src/Core/Banshee.Core/Banshee.IO/Directory.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/Directory.cs
@@ -36,38 +36,38 @@ namespace Banshee.IO
     public static class Directory
     {
         public static bool Exists (string directory)
-    	{
-    	    return Provider.Directory.Exists (directory);
-    	}
+        {
+            return Provider.Directory.Exists (Provider.GetPath (directory));
+        }
 
-    	public static void Create (string directory)
-    	{
-    	    Provider.Directory.Create (directory);
-    	}
+        public static void Create (string directory)
+        {
+            Provider.Directory.Create (Provider.GetPath (directory));
+        }
 
-    	public static void Move (SafeUri from, SafeUri to)
-    	{
-    	    Provider.Directory.Move (from, to);
-    	}
+        public static void Move (SafeUri from, SafeUri to)
+        {
+            Provider.Directory.Move (from, to);
+        }
 
-    	public static void Delete (string directory)
-    	{
-    	    Provider.Directory.Delete (directory);
-    	}
+        public static void Delete (string directory)
+        {
+            Provider.Directory.Delete (Provider.GetPath (directory));
+        }
 
-    	public static void Delete (string directory, bool recursive)
-    	{
-    	    Provider.Directory.Delete (directory, recursive);
-    	}
+        public static void Delete (string directory, bool recursive)
+        {
+            Provider.Directory.Delete (Provider.GetPath (directory), recursive);
+        }
 
-    	public static IEnumerable<string> GetFiles (string directory)
-    	{
-    	    return Provider.Directory.GetFiles (directory);
-    	}
+        public static IEnumerable<string> GetFiles (string directory)
+        {
+            return Provider.Directory.GetFiles (Provider.GetPath (directory));
+        }
 
-    	public static IEnumerable<string> GetDirectories (string directory)
-    	{
-    	    return Provider.Directory.GetDirectories (directory);
-    	}
+        public static IEnumerable<string> GetDirectories (string directory)
+        {
+            return Provider.Directory.GetDirectories (Provider.GetPath (directory));
+        }
     }
 }
diff --git a/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs b/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs
index f8d58d4..f2532ae 100644
--- a/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/IDemuxVfs.cs
@@ -30,5 +30,7 @@ namespace Banshee.IO
 {
     public interface IDemuxVfs : TagLib.File.IFileAbstraction
     {
+        bool IsReadable { get; }
+        bool IsWritable { get; }
     }
 }
diff --git a/src/Core/Banshee.Core/Banshee.IO/Provider.cs b/src/Core/Banshee.Core/Banshee.IO/Provider.cs
index b24df9e..82191fd 100644
--- a/src/Core/Banshee.Core/Banshee.IO/Provider.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/Provider.cs
@@ -106,7 +106,16 @@ namespace Banshee.IO
 
         internal static IDemuxVfs CreateDemuxVfs (string file)
         {
-            return (IDemuxVfs)Activator.CreateInstance (provider.DemuxVfsProvider, new object [] { file });
+            return (IDemuxVfs)Activator.CreateInstance (provider.DemuxVfsProvider, new object [] { GetPath (file) });
+        }
+
+        internal static string GetPath (string uri)
+        {
+            if (LocalOnly && !String.IsNullOrEmpty (uri) && uri[0] != '/' && uri.StartsWith ("file://")) {
+                return uri.Substring (7, uri.Length - 7);
+            }
+
+            return uri;
         }
 
         private static string [] builtin_backend_preference = new string [] {
diff --git a/src/Core/Banshee.Core/Banshee.IO/Tests.cs b/src/Core/Banshee.Core/Banshee.IO/Tests.cs
new file mode 100644
index 0000000..28852b8
--- /dev/null
+++ b/src/Core/Banshee.Core/Banshee.IO/Tests.cs
@@ -0,0 +1,321 @@
+//
+// Tests.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2010 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if ENABLE_TESTS
+
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Reflection;
+using NUnit.Framework;
+
+using Banshee.Base;
+using Banshee.Collection;
+using Banshee.Streaming;
+using Banshee.Configuration.Schema;
+
+using Hyena.Tests;
+
+namespace Banshee.IO
+{
+    [TestFixture]
+    public class Tests : TestBase
+    {
+        private string tmp_dir = System.IO.Path.Combine (System.Environment.CurrentDirectory, "tmp-io-test-dir");
+        private SafeUri foo, baz, zoo;
+        private string woo, yoo;
+
+        private void Setup ()
+        {
+            foo = Uri  ("foo");
+            baz = Uri  ("baz");
+            woo = Path ("woo");
+            zoo = new SafeUri ("file://" + Path ("foo"));
+            yoo = "file://" + tmp_dir;
+
+            System.IO.Directory.CreateDirectory (tmp_dir);
+            System.IO.File.WriteAllText (Path ("foo"), "bar");
+            System.IO.File.WriteAllText (Path ("baz"), "oof");
+            System.IO.Directory.CreateDirectory (Path ("woo"));
+        }
+
+        private void Teardown ()
+        {
+            try { System.IO.File.Delete (Path ("foo")); } catch {}
+            try { System.IO.File.Delete (Path ("baz")); } catch {}
+            try { System.IO.Directory.Delete (woo); } catch {}
+            try { System.IO.Directory.Delete (tmp_dir, true); } catch {}
+        }
+
+        [Test]
+        public void Exists ()
+        {
+            ForEachProvider (() => {
+                Assert.IsTrue (File.Exists (foo));
+                Assert.IsTrue (File.Exists (zoo));
+                Assert.IsTrue (File.Exists (baz));
+                Assert.IsTrue (Directory.Exists (woo));
+                Assert.IsTrue (Directory.Exists (yoo), String.Format ("Directory {0} should exist, but provider {1} says it doesn't", yoo, Provider.Directory));
+            });
+        }
+
+        [Test]
+        public void DoesntExist ()
+        {
+            ForEachProvider (() => {
+                Assert.IsFalse (Directory.Exists (Path ("foo")));
+                Assert.IsFalse (File.Exists (Uri ("woo")));
+                Assert.IsFalse (File.Exists (Uri ("asd")));
+            });
+        }
+
+        [Test]
+        public void Move ()
+        {
+            ForEachProvider (() => {
+                File.Move (foo, Uri ("fooz"));
+                Assert.IsTrue  (File.Exists (Uri ("fooz")));
+                Assert.IsFalse (File.Exists (foo));
+
+                Directory.Move (new SafeUri (woo), Uri ("wooz"));
+                Assert.IsTrue  (Directory.Exists (Path ("wooz")));
+                Assert.IsFalse (Directory.Exists (woo));
+            });
+        }
+
+        [Test]
+        public void Create ()
+        {
+            ForEachProvider (() => {
+                var newf = Uri ("newfile");
+                Assert.IsFalse (File.Exists (newf));
+                File.OpenWrite (newf, false).Close ();
+                Assert.IsTrue (File.Exists (newf));
+
+                try {
+                    File.OpenWrite (newf, false).Close ();
+                    Assert.Fail ("Should have thrown an exception creating already-exists file w/o overwrite");
+                } catch {}
+
+                try {
+                    File.OpenWrite (newf, true).Close ();
+                } catch {
+                    Assert.Fail ("Should not have thrown an exception creating already-exists file w/ overwrite");
+                }
+
+                var newd = Path ("newdir");
+                Assert.IsFalse (Directory.Exists (newd));
+                Directory.Create (newd);
+                Assert.IsTrue (Directory.Exists (newd));
+            });
+        }
+
+        [Test]
+        public void DemuxCreateFile ()
+        {
+            ForEachProvider (() => {
+                var newf = Uri ("newfile");
+                var newp = Path ("newfile");
+
+                File.OpenWrite (newf, false).Close ();
+                Assert.IsTrue (File.Exists (newf));
+
+                var demux = Provider.CreateDemuxVfs (newp);
+                Assert.IsTrue (demux.IsWritable);
+                Assert.IsTrue (demux.IsReadable);
+
+                var stream = demux.WriteStream;
+                Assert.IsTrue (stream.CanWrite);
+                stream.WriteByte (0xAB);
+                demux.CloseStream (stream);
+
+                Assert.IsTrue (File.Exists (newf));
+            });
+        }
+
+        [Test]
+        public void DemuxOverwriteFile ()
+        {
+            ForEachProvider (() => {
+                Assert.IsTrue (File.Exists (foo));
+                Assert.AreEqual (3, File.GetSize (foo));
+
+                var demux = Provider.CreateDemuxVfs (foo.AbsoluteUri);
+                Assert.IsTrue (demux.IsWritable);
+                Assert.IsTrue (demux.IsReadable);
+
+                var stream = demux.WriteStream;
+                Assert.IsTrue (stream.CanWrite);
+                Assert.IsTrue (stream.CanRead);
+
+                // Make sure can actually read from WriteStream - required by TagLib#
+                // stream should contain 'bar', eg first byte == 'b'
+                Assert.AreEqual (3, stream.Length);
+                Assert.AreEqual ((byte)'b', stream.ReadByte (), "Error in GIO backend - shouldn't happen - fix (and the Banshee GIO backend) requires gio 2.22");
+                stream.Position = 0;
+
+                // Replace the first two bytes, and truncate the third
+                stream.WriteByte (0xAB);
+                stream.WriteByte (0xCD);
+                stream.SetLength (2);
+
+                // And verify those bytes are readable
+                stream.Position = 1;
+                Assert.AreEqual (0xCD, stream.ReadByte ());
+                stream.Position = 0;
+                Assert.AreEqual (0xAB, stream.ReadByte ());
+
+                // And make sure the file is now the right size; 2 bytes
+                demux.CloseStream (stream);
+                Assert.IsTrue (File.Exists (foo));
+                Assert.AreEqual (2, File.GetSize (foo));
+            });
+        }
+
+        [Test]
+        public void DemuxReadFile ()
+        {
+            ForEachProvider (() => {
+                Assert.IsTrue (File.Exists (foo));
+
+                var demux = Provider.CreateDemuxVfs (foo.AbsoluteUri);
+                var stream = demux.ReadStream;
+
+                // foo contains 'bar'
+                Assert.AreEqual ((byte)'b', stream.ReadByte ());
+                Assert.AreEqual ((byte)'a', stream.ReadByte ());
+                Assert.AreEqual ((byte)'r', stream.ReadByte ());
+
+                demux.CloseStream (stream);
+            });
+        }
+
+        [Test]
+        public void GetFileProperties ()
+        {
+            ForEachProvider (() => {
+                Assert.AreEqual (3, File.GetSize (foo));
+                Assert.IsTrue (File.GetModifiedTime (foo) > 0);
+            });
+        }
+
+        [Test]
+        public void Delete ()
+        {
+            ForEachProvider (() => {
+                Assert.IsTrue (File.Exists (foo));
+                File.Delete (foo);
+                Assert.IsFalse (File.Exists (foo));
+
+                Assert.IsTrue (Directory.Exists (woo));
+                Directory.Delete (woo);
+                Assert.IsFalse (Directory.Exists (woo));
+            });
+        }
+
+        [Test]
+        public void DeleteRecursive ()
+        {
+            ForEachProvider (() => {
+                Directory.Delete (tmp_dir, true);
+            });
+        }
+
+        [Test]
+        public void GetChildFiles ()
+        {
+            ForEachProvider (() => {
+                var files = Directory.GetFiles (tmp_dir).ToArray ();
+                if (Provider.LocalOnly) {
+                    Assert.AreEqual (new string [] { baz.LocalPath, foo.LocalPath }, files);
+                } else {
+                    Assert.AreEqual (new string [] { foo.AbsoluteUri, baz.AbsoluteUri }, files);
+                }
+            });
+        }
+
+        [Test]
+        public void GetChildDirs ()
+        {
+            ForEachProvider (() => {
+                var dirs = Directory.GetDirectories (tmp_dir).ToArray ();
+                if (Provider.LocalOnly) {
+                    Assert.AreEqual (new string [] { new SafeUri (woo).LocalPath }, dirs);
+                } else {
+                    Assert.AreEqual (new string [] { new SafeUri (woo).AbsoluteUri }, dirs);
+                }
+            });
+        }
+
+        private SafeUri Uri (string filename)
+        {
+            return new SafeUri (Path (filename));
+        }
+
+        private string Path (string filename)
+        {
+            return System.IO.Path.Combine (tmp_dir, filename);
+        }
+
+        private static Banshee.IO.IProvider GetProviderFromAssembly (string name)
+        {
+            var asm = Assembly.LoadFrom (String.Format ("{0}/Banshee.{1}.dll", BinDir, name));
+            var provider_type = asm.GetType (String.Format ("Banshee.IO.{0}.Provider", name));
+            return (Banshee.IO.IProvider)Activator.CreateInstance (provider_type);
+        }
+
+        static List<IProvider> providers = new List<IProvider> ();
+        static Tests ()
+        {
+            GLib.GType.Init ();
+            Mono.Addins.AddinManager.Initialize (BinDir);
+            providers.Add (new Banshee.IO.SystemIO.Provider ());
+            providers.Add (GetProviderFromAssembly ("Unix"));
+            try {
+                providers.Add (GetProviderFromAssembly ("Gio"));
+            } catch (System.IO.FileNotFoundException) {
+            } catch (Exception e) {
+                Console.WriteLine ("Error loading GIO backend: {0}", e);
+            }
+        }
+
+        public static IEnumerable<Banshee.IO.IProvider> Providers { get { return providers; } }
+
+        private void ForEachProvider (System.Action action)
+        {
+            foreach (var provider in providers) {
+                Banshee.IO.Provider.SetProvider (provider);
+                Setup ();
+                action ();
+                Teardown ();
+            }
+        }
+    }
+}
+
+#endif
diff --git a/src/Core/Banshee.Core/Makefile.am b/src/Core/Banshee.Core/Makefile.am
index b8d9625..ae3e4ab 100644
--- a/src/Core/Banshee.Core/Makefile.am
+++ b/src/Core/Banshee.Core/Makefile.am
@@ -50,6 +50,7 @@ SOURCES =  \
 	Banshee.IO/IProvider.cs \
 	Banshee.IO/Provider.cs \
 	Banshee.IO/StreamAssist.cs \
+	Banshee.IO/Tests.cs \
 	Banshee.IO/Utilities.cs \
 	Banshee.Kernel/DelegateJob.cs \
 	Banshee.Kernel/IInstanceCriticalJob.cs \
diff --git a/src/Core/Banshee.Services/Banshee.Metadata/Tests/TaglibReadWriteTests.cs b/src/Core/Banshee.Services/Banshee.Metadata/Tests/TaglibReadWriteTests.cs
index f10d812..2478872 100644
--- a/src/Core/Banshee.Services/Banshee.Metadata/Tests/TaglibReadWriteTests.cs
+++ b/src/Core/Banshee.Services/Banshee.Metadata/Tests/TaglibReadWriteTests.cs
@@ -52,101 +52,105 @@ namespace Banshee.Metadata
         [TestFixtureSetUp]
         public void Setup ()
         {
-            Mono.Addins.AddinManager.Initialize (BinDir);
-
             files = new string [] {
                 Path.Combine (TestsDir, "data/test.mp3")
             };
         }
 
         [Test]
-        public void TestSystemIO ()
-        {
-            Banshee.IO.Provider.SetProvider (new Banshee.IO.SystemIO.Provider ());
-            WriteMetadata (files, ChangeTrack, VerifyTrack);
-        }
-
-        [Test]
-        public void TestUnixIO ()
+        public void TestChangeTrack ()
         {
-            Banshee.IO.Provider.SetProvider (CreateUnixIOProvider ());
-            WriteMetadata (files, ChangeTrack, VerifyTrack);
+            foreach (var p in Banshee.IO.Tests.Providers) {
+                Banshee.IO.Provider.SetProvider (p);
+                WriteMetadata (files, ChangeTrack, VerifyTrack);
+            }
         }
 
         [Test]
         public void TestGenre ()
         {
-            Banshee.IO.Provider.SetProvider (CreateUnixIOProvider ());
-            WriteMetadata (files, delegate (TrackInfo track) {
-                ChangeTrack (track);
-                track.Genre = "My Genre";
-            }, delegate (TrackInfo track) {
-                VerifyTrack (track);
-                Assert.AreEqual ("My Genre", track.Genre);
-            });
+            foreach (var p in Banshee.IO.Tests.Providers) {
+                Banshee.IO.Provider.SetProvider (p);
+                WriteMetadata (files, delegate (TrackInfo track) {
+                    ChangeTrack (track);
+                    track.Genre = "My Genre";
+                }, delegate (TrackInfo track) {
+                    VerifyTrack (track);
+                    Assert.AreEqual ("My Genre", track.Genre);
+                });
+            }
         }
 
         [Test]
         public void TestNullGenreBug ()
         {
-            // Bug in taglib-sharp-2.0.3.0: Crash if you send it a genre of "{ null }" on
-            // a song with both ID3v1 and ID3v2 metadata. It's happy with "{}", though.
-            // (see http://forum.taglib-sharp.com/viewtopic.php?f=5&t=239 )
-            // This tests our workaround.
-            Banshee.IO.Provider.SetProvider (CreateUnixIOProvider ());
-            WriteMetadata (files, delegate (TrackInfo track) {
-                ChangeTrack (track);
-                track.Genre = null;
-            }, delegate (TrackInfo track) {
-                VerifyTrack (track);
-                Assert.IsNull (track.Genre);
-            });
+            foreach (var p in Banshee.IO.Tests.Providers) {
+                Banshee.IO.Provider.SetProvider (p);
+                // Bug in taglib-sharp-2.0.3.0: Crash if you send it a genre of "{ null }" on
+                // a song with both ID3v1 and ID3v2 metadata. It's happy with "{}", though.
+                // (see http://forum.taglib-sharp.com/viewtopic.php?f=5&t=239 )
+                // This tests our workaround.
+                WriteMetadata (files, delegate (TrackInfo track) {
+                    ChangeTrack (track);
+                    track.Genre = null;
+                }, delegate (TrackInfo track) {
+                    VerifyTrack (track);
+                    Assert.IsNull (track.Genre);
+                });
+            }
         }
 
         [Test]
         public void TestIsCompilation ()
         {
-            Banshee.IO.Provider.SetProvider (CreateUnixIOProvider ());
-            WriteMetadata (files, delegate (TrackInfo track) {
-                ChangeTrack (track);
-                // bgo#563283: IsCompilation was reset if AlbumArtist == Artist
-                track.AlbumArtist = track.ArtistName;
-                track.IsCompilation = true;
-            }, delegate (TrackInfo track) {
-                VerifyTrack (track);
-                Assert.AreEqual (track.ArtistName, track.AlbumArtist);
-                Assert.IsTrue (track.IsCompilation);
-            });
+            foreach (var p in Banshee.IO.Tests.Providers) {
+                Banshee.IO.Provider.SetProvider (p);
+
+                WriteMetadata (files, delegate (TrackInfo track) {
+                    ChangeTrack (track);
+                    // bgo#563283: IsCompilation was reset if AlbumArtist == Artist
+                    track.AlbumArtist = track.ArtistName;
+                    track.IsCompilation = true;
+                }, delegate (TrackInfo track) {
+                    VerifyTrack (track);
+                    Assert.AreEqual (track.ArtistName, track.AlbumArtist);
+                    Assert.IsTrue (track.IsCompilation);
+                });
+            }
         }
 
         [Test]
         public void TestIsNotCompilation ()
         {
-            Banshee.IO.Provider.SetProvider (CreateUnixIOProvider ());
-            WriteMetadata (files, delegate (TrackInfo track) {
-                ChangeTrack (track);
-                track.AlbumArtist = track.ArtistName;
-                track.IsCompilation = false;
-            }, delegate (TrackInfo track) {
-                VerifyTrack (track);
-                Assert.AreEqual (track.ArtistName, track.AlbumArtist);
-                Assert.IsFalse (track.IsCompilation);
-            });
+            foreach (var p in Banshee.IO.Tests.Providers) {
+                Banshee.IO.Provider.SetProvider (p);
+                WriteMetadata (files, delegate (TrackInfo track) {
+                    ChangeTrack (track);
+                    track.AlbumArtist = track.ArtistName;
+                    track.IsCompilation = false;
+                }, delegate (TrackInfo track) {
+                    VerifyTrack (track);
+                    Assert.AreEqual (track.ArtistName, track.AlbumArtist);
+                    Assert.IsFalse (track.IsCompilation);
+                });
+            }
         }
 
         [Test]
         public void TestIsCompilationAndAlbumArtist ()
         {
-            Banshee.IO.Provider.SetProvider (CreateUnixIOProvider ());
-            WriteMetadata (files, delegate (TrackInfo track) {
-                ChangeTrack (track);
-                track.AlbumArtist = "My Album Artist";
-                track.IsCompilation = true;
-            }, delegate (TrackInfo track) {
-                VerifyTrack (track);
-                Assert.AreEqual ("My Album Artist", track.AlbumArtist);
-                Assert.IsTrue (track.IsCompilation);
-            });
+            foreach (var p in Banshee.IO.Tests.Providers) {
+                Banshee.IO.Provider.SetProvider (p);
+                WriteMetadata (files, delegate (TrackInfo track) {
+                    ChangeTrack (track);
+                    track.AlbumArtist = "My Album Artist";
+                    track.IsCompilation = true;
+                }, delegate (TrackInfo track) {
+                    VerifyTrack (track);
+                    Assert.AreEqual ("My Album Artist", track.AlbumArtist);
+                    Assert.IsTrue (track.IsCompilation);
+                });
+            }
         }
 
         private void WriteMetadata (string [] files, Action<TrackInfo> change, Action<TrackInfo> verify)
@@ -215,18 +219,6 @@ namespace Banshee.Metadata
             Assert.AreEqual (2, track.Rating);
             Assert.AreEqual (3, track.PlayCount);
         }
-
-        private Type unix_io_type;
-
-        private Banshee.IO.IProvider CreateUnixIOProvider ()
-        {
-            if (unix_io_type == null) {
-                Assembly asm = Assembly.LoadFrom (BinDir + "/Banshee.Unix.dll");
-                unix_io_type = asm.GetType ("Banshee.IO.Unix.Provider");
-            }
-
-            return (Banshee.IO.IProvider)Activator.CreateInstance (unix_io_type);
-        }
     }
 }
 
diff --git a/src/Libraries/Hyena/Makefile.am b/src/Libraries/Hyena/Makefile.am
index 6ebf904..4d15587 100644
--- a/src/Libraries/Hyena/Makefile.am
+++ b/src/Libraries/Hyena/Makefile.am
@@ -140,9 +140,3 @@ SOURCES =  \
 	System.Web/HttpUtility.cs
 
 include $(top_srcdir)/build/build.mk
-
-test: all
-	pushd $(top_srcdir)/tests; \
-	make hyena; \
-	popd
-
diff --git a/src/Libraries/Lastfm/Makefile.am b/src/Libraries/Lastfm/Makefile.am
index 22df01f..ff8b405 100644
--- a/src/Libraries/Lastfm/Makefile.am
+++ b/src/Libraries/Lastfm/Makefile.am
@@ -20,7 +20,7 @@ SOURCES =  \
 
 include $(top_srcdir)/build/build.mk
 
-test: Test.cs
+test-lastfm: Test.cs
 	gmcs -r:$(top_builddir)/bin/Lastfm.dll -out:TestLastfm.exe Test.cs && \
 	mv TestLastfm.exe $(top_builddir)/bin/
 	@pushd $(top_builddir)/bin/; mono --debug TestLastfm.exe; \



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