From 0d6d9a70218ae588ccd34e6b575a427ccf38457e Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Fri, 26 Jul 2013 21:34:11 -0700 Subject: [PATCH] linux fixes --- NzbDrone.Common.Test/DiskProviderFixture.cs | 11 +++++------ .../MediaFileTests/MediaFileRepositoryFixture.cs | 3 ++- NzbDrone.Test.Common/TestBase.cs | 12 +++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/NzbDrone.Common.Test/DiskProviderFixture.cs b/NzbDrone.Common.Test/DiskProviderFixture.cs index c5d1fefea..8e2102ec7 100644 --- a/NzbDrone.Common.Test/DiskProviderFixture.cs +++ b/NzbDrone.Common.Test/DiskProviderFixture.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using FluentAssertions; using NUnit.Framework; -using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Test.Common; namespace NzbDrone.Common.Test @@ -162,14 +161,14 @@ namespace NzbDrone.Common.Test [Test] public void folder_should_return_correct_value_for_last_write() { - var appPath = new AppFolderInfo(Subject).AppDataFolder; + var testFile = Path.Combine(SandboxFolder, "newfile.txt"); - TestLogger.Info("Path is: {0}", appPath); + TestLogger.Info("Path is: {0}", testFile); - Subject.WriteAllText(Path.Combine(appPath, "newfile.txt"), ""); + Subject.WriteAllText(testFile, ""); - Subject.GetLastFolderWrite(appPath).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-10)); - Subject.GetLastFolderWrite(appPath).Should().BeBefore(DateTime.UtcNow); + Subject.GetLastFolderWrite(SandboxFolder).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-1)); + Subject.GetLastFolderWrite(SandboxFolder).Should().BeBefore(DateTime.UtcNow); } [Test] diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs index 4bc76ee62..567a55949 100644 --- a/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileRepositoryFixture.cs @@ -6,6 +6,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Qualities; using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; +using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.MediaFileTests { @@ -49,7 +50,7 @@ namespace NzbDrone.Core.Test.MediaFileTests [Test] public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database() { - var path = @"C:\Test\EpisodeFile.avi"; + var path = @"C:\Test\EpisodeFile.avi".AsOsAgnostic(); var episodeFile = Builder.CreateNew() .With(f => f.Id = 0) diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index 8cf10b54d..72368f671 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -140,9 +140,19 @@ namespace NzbDrone.Test.Common protected string GetTestFilePath(string fileName) { - return Path.Combine(Directory.GetCurrentDirectory(), "Files", fileName); + return Path.Combine(SandboxFolder, fileName); } + protected string SandboxFolder + { + get + { + var folder = Path.Combine(Directory.GetCurrentDirectory(), "Files"); + Directory.CreateDirectory(folder); + return folder; + } + + } protected void VerifyEventPublished() where TEvent : class, IEvent { VerifyEventPublished(Times.Once());