fixing linux tests

pull/6/head
kay.one 12 years ago
parent 9330f0aefc
commit 05370518c5

@ -42,13 +42,15 @@ namespace NzbDrone.Common.Test
[Test]
public void directory_exist_should_be_able_to_find_existing_unc_share()
{
WindowsOnly();
Subject.FolderExists(@"\\localhost\c$").Should().BeTrue();
}
[Test]
public void directory_exist_should_not_be_able_to_find_none_existing_folder()
{
Subject.FolderExists(@"C:\ThisBetterNotExist\").Should().BeFalse();
Subject.FolderExists(@"C:\ThisBetterNotExist\".AsOsAgnostic()).Should().BeFalse();
}
[Test]
@ -140,20 +142,14 @@ namespace NzbDrone.Common.Test
[TestCase(@"\\smallcheese\DRIVE_G\TV-C\Simspsons", @"\\smallcheese\DRIVE_G\TV-C\Simspsons")]
public void paths_should_be_equal(string first, string second)
{
if (first.StartsWith("\\"))
{
//verify the linux equivalent.
DiskProvider.PathEquals(first, second).Should().BeTrue();
}
DiskProvider.PathEquals(first, second).Should().BeTrue();
DiskProvider.PathEquals(first.AsOsAgnostic(), second.AsOsAgnostic()).Should().BeTrue();
}
[TestCase(@"D:\Test", @"C:\Test\")]
[TestCase(@"D:\Test\Test", @"C:\TestTest\")]
[TestCase(@"C:\Test", @"C:\Test2\")]
[TestCase(@"C:\Test\Test", @"C:\TestTest\")]
public void paths_should_not_be_equal(string first, string second)
{
DiskProvider.PathEquals(first, second).Should().BeFalse();
DiskProvider.PathEquals(first.AsOsAgnostic(), second.AsOsAgnostic()).Should().BeFalse();
}
[Test]
@ -180,8 +176,8 @@ namespace NzbDrone.Common.Test
[Explicit]
public void check_last_write()
{
Console.WriteLine(Subject.GetLastFolderWrite(@"C:\DRIVERS"));
Console.WriteLine(new DirectoryInfo(@"C:\DRIVERS").LastWriteTimeUtc);
Console.WriteLine(Subject.GetLastFolderWrite(_binFolder.FullName));
Console.WriteLine(_binFolder.LastWriteTimeUtc);
}
private void VerifyCopy()

@ -8,8 +8,18 @@ namespace NzbDrone.Common.Test.EnsureTest
public class PathExtensionFixture : TestBase
{
[TestCase(@"p:\TV Shows\file with, comma.mkv")]
[TestCase(@"\\serer\share\file with, comma.mkv")]
public void EnsureWindowsPath(string path)
{
WindowsOnly();
Ensure.That(() => path).IsValidPath();
}
[TestCase(@"var/user/file with, comma.mkv")]
public void EnsureLinuxPath(string path)
{
LinuxOnly();
Ensure.That(() => path).IsValidPath();
}
}

@ -17,13 +17,17 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests
{
private const string _nzbUrl = "http://www.nzbs.com/url";
private const string _title = "some_nzb_title";
private const string _blackHoleFolder = @"d:\nzb\blackhole\";
private const string _nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb";
private string _blackHoleFolder;
private string _nzbPath;
private RemoteEpisode _remoteEpisode;
[SetUp]
public void Setup()
{
_blackHoleFolder = @"c:\nzb\blackhole\".AsOsAgnostic();
_nzbPath = @"c:\nzb\blackhole\some_nzb_title.nzb".AsOsAgnostic();
Mocker.GetMock<IConfigService>().SetupGet(c => c.BlackholeFolder).Returns(_blackHoleFolder);
_remoteEpisode = new RemoteEpisode();

@ -10,11 +10,12 @@ using NzbDrone.Common;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.RootFolderTests
{
[TestFixture]
public class RootFolderServiceFixture : CoreTest<RootFolderService>
{
[SetUp]
@ -40,8 +41,8 @@ namespace NzbDrone.Core.Test.RootFolderTests
[TestCase("//server//folder")]
public void should_be_able_to_add_root_dir(string path)
{
var root = new RootFolder { Path = path };
var root = new RootFolder { Path = path.AsOsAgnostic() };
Subject.Add(root);
Mocker.GetMock<IBasicRepository<RootFolder>>().Verify(c => c.Insert(root), Times.Once());
@ -52,7 +53,7 @@ namespace NzbDrone.Core.Test.RootFolderTests
{
WithNoneExistingFolder();
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST" }));
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST".AsOsAgnostic() }));
}
[Test]

@ -97,6 +97,7 @@
<Compile Include="MockerExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="TestException.cs" />
</ItemGroup>

@ -0,0 +1,22 @@
using System.IO;
using NzbDrone.Common.EnvironmentInfo;
namespace NzbDrone.Test.Common
{
public static class StringExtensions
{
public static string AsOsAgnostic(this string path)
{
if (OsInfo.IsLinux)
{
if (path.Length > 2 && path[1] == ':')
{
path = path.Replace(':', Path.DirectorySeparatorChar);
}
path = path.Replace("\\", Path.DirectorySeparatorChar.ToString());
}
return path;
}
}
}
Loading…
Cancel
Save