From c2b4eadc47285d8f378d97fa2d54f0e97f237238 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 25 Jul 2013 22:41:38 -0700 Subject: [PATCH] more linux fixes --- NzbDrone.Common.Test/PathExtensionFixture.cs | 14 +++++++------- .../MediaFileTests/EpisodeFileMoverFixture.cs | 10 +++++----- .../NotExistingFileSpecificationFixture.cs | 13 +++++++------ .../DiskProviderTests/FreeDiskSpaceTest.cs | 3 ++- .../RecycleBinProviderTests/DeleteFileFixture.cs | 15 ++++++++------- .../RootFolderTests/RootFolderServiceFixture.cs | 4 ++-- NzbDrone.Test.Common/StringExtensions.cs | 1 - 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/NzbDrone.Common.Test/PathExtensionFixture.cs b/NzbDrone.Common.Test/PathExtensionFixture.cs index df4e0b575..35b05ac66 100644 --- a/NzbDrone.Common.Test/PathExtensionFixture.cs +++ b/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -109,43 +109,43 @@ namespace NzbDrone.Common.Test [Test] public void AppDataDirectory_path_test() { - GetIAppDirectoryInfo().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\"); + GetIAppDirectoryInfo().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\".AsOsAgnostic()); } [Test] public void Config_path_test() { - GetIAppDirectoryInfo().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml"); + GetIAppDirectoryInfo().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml".AsOsAgnostic()); } [Test] public void Sanbox() { - GetIAppDirectoryInfo().GetUpdateSandboxFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\"); + GetIAppDirectoryInfo().GetUpdateSandboxFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\".AsOsAgnostic()); } [Test] public void GetUpdatePackageFolder() { - GetIAppDirectoryInfo().GetUpdatePackageFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\"); + GetIAppDirectoryInfo().GetUpdatePackageFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\".AsOsAgnostic()); } [Test] public void GetUpdateClientFolder() { - GetIAppDirectoryInfo().GetUpdateClientFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\"); + GetIAppDirectoryInfo().GetUpdateClientFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\".AsOsAgnostic()); } [Test] public void GetUpdateClientExePath() { - GetIAppDirectoryInfo().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone.Update.exe"); + GetIAppDirectoryInfo().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone.Update.exe".AsOsAgnostic()); } [Test] public void GetUpdateLogFolder() { - GetIAppDirectoryInfo().GetUpdateLogFolder().Should().BeEquivalentTo(@"C:\NzbDrone\UpdateLogs\"); + GetIAppDirectoryInfo().GetUpdateLogFolder().Should().BeEquivalentTo(@"C:\NzbDrone\UpdateLogs\".AsOsAgnostic()); } } } diff --git a/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs b/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs index 310288036..3101de684 100644 --- a/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Core.Test.MediaFileTests .Build().ToList(); const string filename = @"30 Rock - S01E01 - TBD"; - var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".avi"); + var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".avi").AsOsAgnostic(); var file = Builder.CreateNew() .With(f => f.SeriesId = fakeSeries.Id) @@ -80,8 +80,8 @@ namespace NzbDrone.Core.Test.MediaFileTests .Build().ToList(); const string filename = @"30 Rock - S01E01 - TBD"; - var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"); - var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv"); + var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv").AsOsAgnostic(); + var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv").AsOsAgnostic(); const string message = "30 Rock - 1x01 - [WEBDL]"; var file = Builder.CreateNew() @@ -131,8 +131,8 @@ namespace NzbDrone.Core.Test.MediaFileTests .Build().ToList(); const string filename = @"30 Rock - S01E01 - TBD"; - var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"); - var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv"); + var fi = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv").AsOsAgnostic(); + var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv").AsOsAgnostic(); const string message = "30 Rock - 1x01 - [WEBDL]"; var file = Builder.CreateNew() diff --git a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotExistingFileSpecificationFixture.cs b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotExistingFileSpecificationFixture.cs index d4d9d6177..aa29dce0a 100644 --- a/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotExistingFileSpecificationFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/EpisodeImportTests/NotExistingFileSpecificationFixture.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests { @@ -22,7 +23,7 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests { _localEpisode = new LocalEpisode { - Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", + Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(), Size = 100 }; } @@ -36,7 +37,7 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests .With(e => e.EpisodeFile = new LazyLoaded( new EpisodeFile { - Path = @"C:\Test\30 Rock\30.rock.s01e01.avi", + Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(), Size = 100 })) .Build() @@ -54,7 +55,7 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests .With(e => e.EpisodeFile = new LazyLoaded( new EpisodeFile { - Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi", + Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi".AsOsAgnostic(), Size = 100 })) .Build() @@ -84,7 +85,7 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests .With(e => e.EpisodeFile = new LazyLoaded( new EpisodeFile { - Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi", + Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi".AsOsAgnostic(), Size = 50 })) .Build() @@ -102,7 +103,7 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests .With(e => e.EpisodeFile = new LazyLoaded( new EpisodeFile { - Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi", + Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi".AsOsAgnostic(), Size = 100 })) .Build() @@ -124,7 +125,7 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests .With(e => e.EpisodeFile = new LazyLoaded( new EpisodeFile { - Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi", + Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi".AsOsAgnostic(), Size = 100 })) .Build() diff --git a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs index cd796b0ac..618b57a45 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskProviderTests/FreeDiskSpaceTest.cs @@ -3,6 +3,7 @@ using FluentAssertions; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests { @@ -28,7 +29,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskProviderTests [Test] public void should_throw_if_drive_doesnt_exist() { - Assert.Throws(() => Subject.GetAvilableSpace(@"Z:\NOT_A_REAL_PATH\DOES_NOT_EXIST")); + Assert.Throws(() => Subject.GetAvilableSpace(@"Z:\NOT_A_REAL_PATH\DOES_NOT_EXIST".AsOsAgnostic())); } } } diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs index e1c3e6943..49f5c6582 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs @@ -7,16 +7,17 @@ using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Test.Framework; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { [TestFixture] - + public class DeleteFileFixture : CoreTest { private void WithRecycleBin() { - Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin"); + Mocker.GetMock().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin".AsOsAgnostic()); } private void WithoutRecycleBin() @@ -29,7 +30,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { WithoutRecycleBin(); - var path = @"C:\Test\TV\30 Rock\S01E01.avi"; + var path = @"C:\Test\TV\30 Rock\S01E01.avi".AsOsAgnostic(); Mocker.Resolve().DeleteFile(path); @@ -41,23 +42,23 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests { WithRecycleBin(); - var path = @"C:\Test\TV\30 Rock\S01E01.avi"; + var path = @"C:\Test\TV\30 Rock\S01E01.avi".AsOsAgnostic(); Mocker.Resolve().DeleteFile(path); - Mocker.GetMock().Verify(v => v.MoveFile(path, @"C:\Test\Recycle Bin\S01E01.avi"), Times.Once()); + Mocker.GetMock().Verify(v => v.MoveFile(path, @"C:\Test\Recycle Bin\S01E01.avi".AsOsAgnostic()), Times.Once()); } [Test] public void should_call_fileSetLastWriteTime_for_each_file() { WithRecycleBin(); - var path = @"C:\Test\TV\30 Rock\S01E01.avi"; + var path = @"C:\Test\TV\30 Rock\S01E01.avi".AsOsAgnostic(); Mocker.Resolve().DeleteFile(path); - Mocker.GetMock().Verify(v => v.FileSetLastWriteTimeUtc(@"C:\Test\Recycle Bin\S01E01.avi", It.IsAny()), Times.Once()); + Mocker.GetMock().Verify(v => v.FileSetLastWriteTimeUtc(@"C:\Test\Recycle Bin\S01E01.avi".AsOsAgnostic(), It.IsAny()), Times.Once()); } } } diff --git a/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs b/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs index 8f5bf7b99..6ffbfde6c 100644 --- a/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs +++ b/NzbDrone.Core.Test/RootFolderTests/RootFolderServiceFixture.cs @@ -97,9 +97,9 @@ namespace NzbDrone.Core.Test.RootFolderTests [Test] public void adding_duplicated_root_folder_should_throw() { - Mocker.GetMock>().Setup(c => c.All()).Returns(new List { new RootFolder { Path = "C:\\TV" } }); + Mocker.GetMock>().Setup(c => c.All()).Returns(new List { new RootFolder { Path = "C:\\TV".AsOsAgnostic() } }); - Assert.Throws(() => Subject.Add(new RootFolder { Path = @"C:\TV" })); + Assert.Throws(() => Subject.Add(new RootFolder { Path = @"C:\TV".AsOsAgnostic() })); } } } \ No newline at end of file diff --git a/NzbDrone.Test.Common/StringExtensions.cs b/NzbDrone.Test.Common/StringExtensions.cs index 3385a87d2..19da86cc1 100644 --- a/NzbDrone.Test.Common/StringExtensions.cs +++ b/NzbDrone.Test.Common/StringExtensions.cs @@ -12,7 +12,6 @@ namespace NzbDrone.Test.Common if (path.Length > 2 && path[1] == ':') { path = path.Replace(':', Path.DirectorySeparatorChar); - path = Path.DirectorySeparatorChar + path; } path = path.Replace("\\", Path.DirectorySeparatorChar.ToString()); }