[banshee] [Banshee.IO] Test providers' Copy method
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Banshee.IO] Test providers' Copy method
- Date: Fri, 19 Mar 2010 20:26:58 +0000 (UTC)
commit e1b8a0fe366661bead40d20e0f6f5cbb2db4998a
Author: Gabriel Burt <gabriel burt gmail com>
Date: Fri Mar 19 13:26:13 2010 -0700
[Banshee.IO] Test providers' Copy method
Fix the GIO backend's Copy method; was Moving
src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs | 4 +-
src/Core/Banshee.Core/Banshee.IO/Tests.cs | 40 ++++++++++++++++++++++-
2 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs b/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
index b535c39..3595a59 100644
--- a/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
+++ b/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
@@ -59,7 +59,7 @@ namespace Banshee.IO.Gio
public void Copy (SafeUri from, SafeUri to, bool overwrite)
{
- FileFactory.NewForUri (from.AbsoluteUri).Move (FileFactory.NewForUri (to.AbsoluteUri), overwrite ? FileCopyFlags.Overwrite : FileCopyFlags.None, null, null);
+ FileFactory.NewForUri (from.AbsoluteUri).Copy (FileFactory.NewForUri (to.AbsoluteUri), overwrite ? FileCopyFlags.Overwrite : FileCopyFlags.None, null, null);
}
public System.IO.Stream OpenRead (SafeUri uri)
@@ -96,4 +96,4 @@ namespace Banshee.IO.Gio
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Core/Banshee.Core/Banshee.IO/Tests.cs b/src/Core/Banshee.Core/Banshee.IO/Tests.cs
index 28852b8..abe183b 100644
--- a/src/Core/Banshee.Core/Banshee.IO/Tests.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/Tests.cs
@@ -100,7 +100,7 @@ namespace Banshee.IO
ForEachProvider (() => {
File.Move (foo, Uri ("fooz"));
Assert.IsTrue (File.Exists (Uri ("fooz")));
- Assert.IsFalse (File.Exists (foo));
+ Assert.IsFalse (File.Exists (foo), "Original file should not exist after being moved");
Directory.Move (new SafeUri (woo), Uri ("wooz"));
Assert.IsTrue (Directory.Exists (Path ("wooz")));
@@ -109,6 +109,35 @@ namespace Banshee.IO
}
[Test]
+ public void Copy ()
+ {
+ ForEachProvider (() => {
+ var fooz = Uri ("fooz");
+ Assert.IsFalse (File.Exists (fooz));
+
+ File.Copy (foo, fooz, false);
+ Assert.IsTrue (File.Exists (fooz));
+ Assert.IsTrue (File.Exists (foo), String.Format ("{0}: Original file should still exist after being copied", Provider.File));
+ Assert.AreEqual (File.GetSize (foo), File.GetSize (fooz));
+ Assert.AreEqual ("bar", GetContents (fooz));
+ });
+ }
+
+ [Test]
+ public void CopyWithOverwrite ()
+ {
+ ForEachProvider (() => {
+ Assert.IsTrue (File.Exists (baz));
+ Assert.AreEqual ("oof", GetContents (baz));
+
+ File.Copy (foo, baz, true);
+ Assert.IsTrue (File.Exists (baz));
+ Assert.IsTrue (File.Exists (foo), String.Format ("{0}: Original file should still exist after being copied", Provider.File));
+ Assert.AreEqual ("bar", GetContents (baz));
+ });
+ }
+
+ [Test]
public void Create ()
{
ForEachProvider (() => {
@@ -272,6 +301,15 @@ namespace Banshee.IO
});
}
+ private string GetContents (SafeUri uri)
+ {
+ var demux = Provider.CreateDemuxVfs (uri.AbsoluteUri);
+ using (var stream = demux.ReadStream) {
+ var reader = new System.IO.StreamReader (stream);
+ return reader.ReadToEnd ();
+ }
+ }
+
private SafeUri Uri (string filename)
{
return new SafeUri (Path (filename));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]