fixing linux tests

pull/2/head
kay.one 11 years ago
parent 9330f0aefc
commit 05370518c5

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

@ -8,8 +8,18 @@ namespace NzbDrone.Common.Test.EnsureTest
public class PathExtensionFixture : TestBase public class PathExtensionFixture : TestBase
{ {
[TestCase(@"p:\TV Shows\file with, comma.mkv")] [TestCase(@"p:\TV Shows\file with, comma.mkv")]
[TestCase(@"\\serer\share\file with, comma.mkv")]
public void EnsureWindowsPath(string path) 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(); 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 _nzbUrl = "http://www.nzbs.com/url";
private const string _title = "some_nzb_title"; private const string _title = "some_nzb_title";
private const string _blackHoleFolder = @"d:\nzb\blackhole\"; private string _blackHoleFolder;
private const string _nzbPath = @"d:\nzb\blackhole\some_nzb_title.nzb"; private string _nzbPath;
private RemoteEpisode _remoteEpisode; private RemoteEpisode _remoteEpisode;
[SetUp] [SetUp]
public void 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); Mocker.GetMock<IConfigService>().SetupGet(c => c.BlackholeFolder).Returns(_blackHoleFolder);
_remoteEpisode = new RemoteEpisode(); _remoteEpisode = new RemoteEpisode();

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

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