mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
fixing linux tests
This commit is contained in:
parent
9330f0aefc
commit
05370518c5
@ -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()
|
||||
|
@ -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 @@ 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();
|
||||
|
@ -10,11 +10,12 @@
|
||||
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 @@ 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);
|
||||
|
||||
Mocker.GetMock<IBasicRepository<RootFolder>>().Verify(c => c.Insert(root), Times.Once());
|
||||
@ -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]
|
||||
|
@ -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>
|
||||
|
22
NzbDrone.Test.Common/StringExtensions.cs
Normal file
22
NzbDrone.Test.Common/StringExtensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user