diff --git a/NzbDrone.App.Test/NzbDrone.App.Test.ncrunchproject b/NzbDrone.App.Test/NzbDrone.App.Test.ncrunchproject index 8641d3614..514d01a85 100644 --- a/NzbDrone.App.Test/NzbDrone.App.Test.ncrunchproject +++ b/NzbDrone.App.Test/NzbDrone.App.Test.ncrunchproject @@ -1,6 +1,6 @@ false - false + true false true false @@ -13,7 +13,10 @@ true true 60000 - - + + + AutoDetect + STA + x86 \ No newline at end of file diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj index b42407546..04d816414 100644 --- a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj +++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj @@ -83,7 +83,7 @@ - + diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject b/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject index 6fc4c6260..f5ddf272f 100644 --- a/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject +++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.ncrunchproject @@ -1,6 +1,6 @@ false - false + true false true false @@ -44,9 +44,6 @@ NzbDrone\.Common\.Test\.EventingTests\.ServiceNameFixture\..* - - NzbDrone\.Common\.Test\.PathExtentionFixture\..* - NzbDrone\.Common\.Test\.ProcessProviderTests\..* diff --git a/NzbDrone.Common.Test/PathExtensionFixture.cs b/NzbDrone.Common.Test/PathExtensionFixture.cs new file mode 100644 index 000000000..91471b877 --- /dev/null +++ b/NzbDrone.Common.Test/PathExtensionFixture.cs @@ -0,0 +1,118 @@ +using System; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Test.Common; +using NzbDrone.Test.Common.Categories; + +namespace NzbDrone.Common.Test +{ + [TestFixture] + public class PathExtensionFixture : TestBase + { + + private EnvironmentProvider GetEnvironmentProvider() + { + var fakeEnvironment = new Mock(); + + fakeEnvironment.SetupGet(c => c.WorkingDirectory).Returns(@"C:\NzbDrone\"); + + fakeEnvironment.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\"); + + return fakeEnvironment.Object; + } + + [TestCase(@"c:\test\", @"c:\test")] + [TestCase(@"c:\\test\\", @"c:\test")] + [TestCase(@"C:\\Test\\", @"C:\Test")] + [TestCase(@"C:\\Test\\Test\", @"C:\Test\Test")] + [TestCase(@"\\Testserver\Test\", @"\\Testserver\Test")] + [TestCase(@"\\Testserver\\Test\", @"\\Testserver\Test")] + [TestCase(@"\\Testserver\Test\file.ext", @"\\Testserver\Test\file.ext")] + [TestCase(@"\\Testserver\Test\file.ext\\", @"\\Testserver\Test\file.ext")] + [TestCase(@"\\Testserver\Test\file.ext \\", @"\\Testserver\Test\file.ext")] + public void Normalize_Path_Windows(string dirty, string clean) + { + var result = dirty.CleanPath(); + result.Should().Be(clean); + } + + [TestCase(@"/test/", @"/test")] + [TestCase(@"//test/", @"/test")] + [TestCase(@"//test//", @"/test")] + [TestCase(@"//test// ", @"/test")] + [TestCase(@"//test//other// ", @"/test/other")] + [TestCase(@"//test//other//file.ext ", @"/test/other/file.ext")] + [TestCase(@"//CAPITAL//lower// ", @"/CAPITAL/lower")] + public void Normalize_Path_Linux(string dirty, string clean) + { + var result = dirty.CleanPath(); + result.Should().Be(clean); + } + + [Test] + public void normalize_path_exception_empty() + { + Assert.Throws(() => "".CleanPath()); + ExceptionVerification.ExpectedWarns(1); + } + + [Test] + public void normalize_path_exception_null() + { + string nullPath = null; + Assert.Throws(() => nullPath.CleanPath()); + ExceptionVerification.ExpectedWarns(1); + } + + + [Test] + public void AppDataDirectory_path_test() + { + GetEnvironmentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\"); + } + + + [Test] + public void Config_path_test() + { + GetEnvironmentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml"); + } + + [Test] + public void Sanbox() + { + GetEnvironmentProvider().GetUpdateSandboxFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\"); + } + + [Test] + public void GetUpdatePackageFolder() + { + GetEnvironmentProvider().GetUpdatePackageFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\"); + } + + [Test] + public void GetUpdateClientFolder() + { + GetEnvironmentProvider().GetUpdateClientFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\"); + } + + [Test] + public void GetUpdateClientExePath() + { + GetEnvironmentProvider().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone.Update.exe"); + } + + [Test] + public void GetSandboxLogFolder() + { + GetEnvironmentProvider().GetSandboxLogFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\UpdateLogs\"); + } + + [Test] + public void GetUpdateLogFolder() + { + GetEnvironmentProvider().GetUpdateLogFolder().Should().BeEquivalentTo(@"C:\NzbDrone\UpdateLogs\"); + } + } +} diff --git a/NzbDrone.Common.Test/PathExtentionFixture.cs b/NzbDrone.Common.Test/PathExtentionFixture.cs deleted file mode 100644 index a4420dced..000000000 --- a/NzbDrone.Common.Test/PathExtentionFixture.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Linq; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Test.Common; - -namespace NzbDrone.Common.Test -{ - [TestFixture] - public class PathExtentionFixture : TestBase - { - - private EnvironmentProvider GetEnviromentProvider() - { - var envMoq = new Mock(); - - envMoq.SetupGet(c => c.WorkingDirectory).Returns(@"C:\NzbDrone\"); - - envMoq.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\"); - - return envMoq.Object; - } - - [TestCase(@"c:\test\", @"c:\test")] - [TestCase(@"c:\\test\\", @"c:\test")] - [TestCase(@"C:\\Test\\", @"C:\Test")] - [TestCase(@"C:\\Test\\Test\", @"C:\Test\Test")] - [TestCase(@"\\Testserver\Test\", @"\\Testserver\Test")] - public void Normalize_Path(string dirty, string clean) - { - var result = dirty.NormalizePath(); - result.Should().Be(clean); - } - - [Test] - public void normalize_path_exception_empty() - { - Assert.Throws(()=> "".NormalizePath()); - ExceptionVerification.ExpectedWarns(1); - - - } - - [Test] - public void normalize_path_exception_null() - { - string nullPath = null; - Assert.Throws(() => nullPath.NormalizePath()); - ExceptionVerification.ExpectedWarns(1); - } - - - [Test] - public void AppDataDirectory_path_test() - { - GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\"); - } - - - [Test] - public void Config_path_test() - { - GetEnviromentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml"); - } - - [Test] - public void Sanbox() - { - GetEnviromentProvider().GetUpdateSandboxFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\"); - } - - [Test] - public void GetUpdatePackageFolder() - { - GetEnviromentProvider().GetUpdatePackageFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\"); - } - - [Test] - public void GetUpdateClientFolder() - { - GetEnviromentProvider().GetUpdateClientFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\"); - } - - [Test] - public void GetUpdateClientExePath() - { - GetEnviromentProvider().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone.Update.exe"); - } - - [Test] - public void GetSandboxLogFolder() - { - GetEnviromentProvider().GetSandboxLogFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\UpdateLogs\"); - } - - [Test] - public void GetUpdateLogFolder() - { - GetEnviromentProvider().GetUpdateLogFolder().Should().BeEquivalentTo(@"C:\NzbDrone\UpdateLogs\"); - } - } -} diff --git a/NzbDrone.Common/DiskProvider.cs b/NzbDrone.Common/DiskProvider.cs index 31501f7ea..315ea8cdd 100644 --- a/NzbDrone.Common/DiskProvider.cs +++ b/NzbDrone.Common/DiskProvider.cs @@ -229,7 +229,7 @@ public virtual void WriteAllText(string filename, string contents) public static bool PathEquals(string firstPath, string secondPath) { - return String.Equals(firstPath.NormalizePath(), secondPath.NormalizePath(), StringComparison.InvariantCultureIgnoreCase); + return String.Equals(firstPath.CleanPath(), secondPath.CleanPath(), StringComparison.InvariantCultureIgnoreCase); } public virtual void FileSetLastWriteTimeUtc(string path, DateTime dateTime) diff --git a/NzbDrone.Common/PathExtensions.cs b/NzbDrone.Common/PathExtensions.cs index 689b37563..8cc02afc3 100644 --- a/NzbDrone.Common/PathExtensions.cs +++ b/NzbDrone.Common/PathExtensions.cs @@ -6,19 +6,19 @@ namespace NzbDrone.Common { public static class PathExtensions { - private const string APP_DATA = "App_Data\\"; - private const string APP_CONFIG_FILE = "config.xml"; - private const string NZBDRONE_DB = "nzbdrone.db"; - private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip"; + private static readonly string APP_DATA = "App_Data" + Path.DirectorySeparatorChar; + private static readonly string APP_CONFIG_FILE = "config.xml"; + private static readonly string NZBDRONE_DB = "nzbdrone.db"; + private static readonly string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip"; - private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update\\"; - private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\"; - private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\"; - private const string UPDATE_CLIENT_EXE = "nzbdrone.update.exe"; - private const string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update\\"; - private const string UPDATE_LOG_FOLDER_NAME = "UpdateLogs\\"; + private static readonly string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update" + Path.DirectorySeparatorChar; + private static readonly string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone" + Path.DirectorySeparatorChar; + private static readonly string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup" + Path.DirectorySeparatorChar; + private static readonly string UPDATE_CLIENT_EXE = "nzbdrone.update.exe"; + private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar; + private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + Path.DirectorySeparatorChar; - public static string NormalizePath(this string path) + public static string CleanPath(this string path) { Ensure.That(() => path).IsNotNullOrWhiteSpace(); diff --git a/NzbDrone.Common/StringExtention.cs b/NzbDrone.Common/StringExtention.cs index e680f3082..f331c0de2 100644 --- a/NzbDrone.Common/StringExtention.cs +++ b/NzbDrone.Common/StringExtention.cs @@ -1,6 +1,6 @@ namespace NzbDrone.Common { - public static class StringExtention + public static class StringExtension { public static object NullSafe(this object target) diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs index 081333bd7..b90f0995d 100644 --- a/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs @@ -70,7 +70,7 @@ public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database() var episodeFile = Builder.CreateNew() .With(f => f.Id = 0) - .With(f => f.Path = path.NormalizePath()) + .With(f => f.Path = path.CleanPath()) .Build(); Subject.Insert(episodeFile); @@ -79,7 +79,7 @@ public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database() //Resolve file.Should().NotBeNull(); - file.Path.Should().Be(path.NormalizePath()); + file.Path.Should().Be(path.CleanPath()); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs index 376c07f43..6a02e3c60 100644 --- a/NzbDrone.Core.Test/ParserTests/ParserFixture.cs +++ b/NzbDrone.Core.Test/ParserTests/ParserFixture.cs @@ -96,8 +96,11 @@ public void ParseTitle_single(string postTitle, string title, int seasonNumber, [TestCase("C:/Test/TV/Chuck.4x05.HDTV.XviD-LOL", 4, 5)] [TestCase(@"P:\TV Shows\House\Season 6\S06E13 - 5 to 9 - 720p BluRay.mkv", 6, 13)] [TestCase(@"S:\TV Drop\House - 10x11 - Title [SDTV]\1011 - Title.avi", 10, 11)] + [TestCase(@"/TV Drop/House - 10x11 - Title [SDTV]/1011 - Title.avi", 10, 11)] [TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV]\1012 - 24 Hour Propane People.avi", 10, 12)] + [TestCase(@"/TV Drop/King of the Hill - 10x12 - 24 Hour Propane People [SDTV]/1012 - 24 Hour Propane People.avi", 10, 12)] [TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV]\Hour Propane People.avi", 10, 12)] + [TestCase(@"/TV Drop/King of the Hill - 10x12 - 24 Hour Propane People [SDTV]/Hour Propane People.avi", 10, 12)] public void PathParse_tests(string path, int season, int episode) { var result = Parser.Parser.ParsePath(path); diff --git a/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs b/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs index ff14791f2..462384a39 100644 --- a/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs +++ b/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs @@ -20,7 +20,7 @@ public class QualityParserFixture : CoreTest new object[] { "WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", Quality.DVD, false }, new object[] { "WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", Quality.DVD, false }, new object[] { "Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", Quality.HDTV720p, false }, - new object[] { "Chuck S11E03 has no periods or extention HDTV", Quality.SDTV, false }, + new object[] { "Chuck S11E03 has no periods or extension HDTV", Quality.SDTV, false }, new object[] { "Chuck.S04E05.HDTV.XviD-LOL", Quality.SDTV, false }, new object[] { "The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", Quality.DVD, false }, new object[] { "The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", Quality.DVD, false }, diff --git a/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs b/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs index f989ce825..69efcc491 100644 --- a/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs +++ b/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs @@ -9,6 +9,7 @@ using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Update; using NzbDrone.Test.Common; +using NzbDrone.Test.Common.Categories; namespace NzbDrone.Core.Test.UpdateTests { diff --git a/NzbDrone.Core/Indexers/Nzbx/NzbxRecentItem.cs b/NzbDrone.Core/Indexers/Nzbx/NzbxRecentItem.cs index e20b57ea1..363db6f07 100644 --- a/NzbDrone.Core/Indexers/Nzbx/NzbxRecentItem.cs +++ b/NzbDrone.Core/Indexers/Nzbx/NzbxRecentItem.cs @@ -24,20 +24,9 @@ public class NzbxRecentItem // "downvotes": 0 //} - public int Id { get; set; } public string Name { get; set; } - public int TotalPart { get; set; } - public int GroupId { get; set; } public long Size { get; set; } public DateTime PostDate { get; set; } public string Guid { get; set; } - public string FromName { get; set; } - public int Completion { get; set; } - public int CategoryId { get; set; } - public string ImdbId { get; set; } - public string AnidbId { get; set; } - public long RageId { get; set; } - public int Comments { get; set; } - public int Downloads { get; set; } } } diff --git a/NzbDrone.Core/MediaFiles/MediaFileService.cs b/NzbDrone.Core/MediaFiles/MediaFileService.cs index 83a1693ae..ccb856329 100644 --- a/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -81,7 +81,7 @@ public void HandleAsync(SeriesDeletedEvent message) _mediaFileRepository.DeleteMany(files); } - public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention) + public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extension) { string path = series.Path; if (series.SeasonFolder) @@ -93,7 +93,7 @@ public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileNa path = Path.Combine(path, seasonFolder); } - path = Path.Combine(path, fileName + extention); + path = Path.Combine(path, fileName + extension); return new FileInfo(path); } diff --git a/NzbDrone.Core/Providers/IDiskScanService.cs b/NzbDrone.Core/Providers/IDiskScanService.cs index d9446554c..653c54b35 100644 --- a/NzbDrone.Core/Providers/IDiskScanService.cs +++ b/NzbDrone.Core/Providers/IDiskScanService.cs @@ -96,11 +96,11 @@ public virtual EpisodeFile ImportFile(Series series, string filePath) var episodeFile = new EpisodeFile(); episodeFile.DateAdded = DateTime.Now; episodeFile.SeriesId = series.Id; - episodeFile.Path = filePath.NormalizePath(); + episodeFile.Path = filePath.CleanPath(); episodeFile.Size = size; episodeFile.Quality = parsedEpisode.Quality; episodeFile.SeasonNumber = parsedEpisode.SeasonNumber; - episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath()); + episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.CleanPath()); //Todo: We shouldn't actually import the file until we confirm its the only one we want. //Todo: Separate episodeFile creation from importing (pass file to import to import) diff --git a/NzbDrone.Test.Common/IntegrationTest.cs b/NzbDrone.Test.Common/Categories/IntegrationTestAttribute.cs similarity index 67% rename from NzbDrone.Test.Common/IntegrationTest.cs rename to NzbDrone.Test.Common/Categories/IntegrationTestAttribute.cs index 040ac9882..43d46f0fe 100644 --- a/NzbDrone.Test.Common/IntegrationTest.cs +++ b/NzbDrone.Test.Common/Categories/IntegrationTestAttribute.cs @@ -1,11 +1,11 @@ using NUnit.Framework; -namespace NzbDrone.Test.Common +namespace NzbDrone.Test.Common.Categories { public class IntegrationTestAttribute : CategoryAttribute { public IntegrationTestAttribute() - : base("Integration Test") + : base("IntegrationTest") { } diff --git a/NzbDrone.Test.Common/LoggingTest.cs b/NzbDrone.Test.Common/LoggingTest.cs index 6d6938470..0e3961df6 100644 --- a/NzbDrone.Test.Common/LoggingTest.cs +++ b/NzbDrone.Test.Common/LoggingTest.cs @@ -41,7 +41,10 @@ public void LoggingTestSetup() [TearDown] public void LoggingDownBase() { - ExceptionVerification.AssertNoUnexcpectedLogs(); + if (TestContext.CurrentContext.Result.Status == TestStatus.Passed) + { + ExceptionVerification.AssertNoUnexcpectedLogs(); + } } } } diff --git a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj index 8d12bda0d..cb63cc806 100644 --- a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj +++ b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj @@ -91,7 +91,7 @@ - + diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index 6d161abf5..1f8231096 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -34,6 +34,7 @@ protected TSubject Subject } } + } public abstract class TestBase : LoggingTest @@ -101,6 +102,20 @@ public void TestBaseTearDown() catch (Exception) { } + + if (TestContext.CurrentContext.Result.Status == TestStatus.Failed) + { + var testName = TestContext.CurrentContext.Test.Name.ToLower(); + + if (EnvironmentProvider.IsLinux && testName.Contains("windows")) + { + throw new IgnoreException("windows specific test"); + } + else if (testName.Contains("linux")) + { + throw new IgnoreException("linux specific test"); + } + } } protected void WithTempAsAppPath() diff --git a/NzbDrone.Update.Test/NzbDrone.Update.Test.ncrunchproject b/NzbDrone.Update.Test/NzbDrone.Update.Test.ncrunchproject index 8641d3614..514d01a85 100644 --- a/NzbDrone.Update.Test/NzbDrone.Update.Test.ncrunchproject +++ b/NzbDrone.Update.Test/NzbDrone.Update.Test.ncrunchproject @@ -1,6 +1,6 @@ false - false + true false true false @@ -13,7 +13,10 @@ true true 60000 - - + + + AutoDetect + STA + x86 \ No newline at end of file