more linux fixes

This commit is contained in:
kay.one 2013-07-25 23:25:03 -07:00
parent 035434468e
commit aee31d1bc2
2 changed files with 22 additions and 6 deletions

View File

@ -79,7 +79,7 @@ namespace NzbDrone.Common.Test
} }
[Test] [Test]
public void get_actual_casing_should_return_actual_casing_for_local_file() public void get_actual_casing_should_return_actual_casing_for_local_file_in_windows()
{ {
var path = Process.GetCurrentProcess().MainModule.FileName; var path = Process.GetCurrentProcess().MainModule.FileName;
path.ToUpper().GetActualCasing().Should().Be(path); path.ToUpper().GetActualCasing().Should().Be(path);
@ -87,14 +87,32 @@ namespace NzbDrone.Common.Test
} }
[Test] [Test]
public void get_actual_casing_should_return_actual_casing_for_local_dir() public void get_actual_casing_should_return_origibal_value_in_linux()
{ {
var path = Process.GetCurrentProcess().MainModule.FileName;
path.GetActualCasing().Should().Be(path);
path.GetActualCasing().Should().Be(path);
}
[Test]
public void get_actual_casing_should_return_actual_casing_for_local_dir_in_windows()
{
WindowsOnly();
var path = Directory.GetCurrentDirectory(); var path = Directory.GetCurrentDirectory();
path.ToUpper().GetActualCasing().Should().Be(path); path.ToUpper().GetActualCasing().Should().Be(path);
path.ToLower().GetActualCasing().Should().Be(path); path.ToLower().GetActualCasing().Should().Be(path);
} }
[Test]
public void get_actual_casing_should_return_original_value_in_linux()
{
WindowsOnly();
var path = Directory.GetCurrentDirectory();
path.GetActualCasing().Should().Be(path);
path.GetActualCasing().Should().Be(path);
}
[Test] [Test]
[Explicit] [Explicit]
public void get_actual_casing_should_return_original_casing_for_shares() public void get_actual_casing_should_return_original_casing_for_shares()
@ -103,9 +121,6 @@ namespace NzbDrone.Common.Test
path.GetActualCasing().Should().Be(path); path.GetActualCasing().Should().Be(path);
} }
[Test] [Test]
public void AppDataDirectory_path_test() public void AppDataDirectory_path_test()
{ {

View File

@ -22,8 +22,9 @@ namespace NzbDrone.Common
public static string CleanFilePath(this string path) public static string CleanFilePath(this string path)
{ {
Ensure.That(() => path).IsNotNullOrWhiteSpace(); Ensure.That(() => path).IsNotNullOrWhiteSpace();
Ensure.That(() => path).IsValidPath();
var info = new FileInfo(path); var info = new FileInfo(path.Trim());
if (!OsInfo.IsLinux && info.FullName.StartsWith(@"\\")) //UNC if (!OsInfo.IsLinux && info.FullName.StartsWith(@"\\")) //UNC
{ {