1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

fixing linux tests

This commit is contained in:
kay.one 2013-07-25 22:00:57 -07:00
parent 9330f0aefc
commit 05370518c5
6 changed files with 53 additions and 19 deletions

View File

@ -42,13 +42,15 @@ public void directory_exist_should_be_able_to_find_existing_folder()
[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 @@ public void MoveFolder_should_overwrite_existing_folder()
[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 @@ public void folder_should_return_correct_value_for_last_write()
[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()

View File

@ -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();
}
}

View File

@ -17,13 +17,17 @@ public class BlackholeProviderFixture : CoreTest<BlackholeProvider>
{
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();

View File

@ -10,6 +10,7 @@
using NzbDrone.Core.Datastore;
using NzbDrone.Core.RootFolders;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.RootFolderTests
{
@ -40,7 +41,7 @@ private void WithNoneExistingFolder()
[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);
@ -52,7 +53,7 @@ public void should_throw_if_folder_being_added_doesnt_exist()
{
WithNoneExistingFolder();
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST" }));
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST".AsOsAgnostic() }));
}
[Test]

View File

@ -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>

View File

@ -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;
}
}
}