@ -133,11 +133,16 @@ namespace NzbDrone.Common.Test
[TestCase(@"C:\test\", @"C:\Test\mydir")]
[TestCase(@"C:\test", @"C:\Test\mydir\")]
public void path_should_be_parent_on_windows_only ( string parentPath , string childPath )
public void windows_ path_should_be_parent( string parentPath , string childPath )
{
var expectedResult = OsInfo . IsWindows ;
parentPath . IsParentPath ( childPath ) . Should ( ) . Be ( true ) ;
}
parentPath . IsParentPath ( childPath ) . Should ( ) . Be ( expectedResult ) ;
[TestCase("/test", "/test/mydir/")]
[TestCase("/test/", "/test/mydir")]
public void posix_path_should_be_parent ( string parentPath , string childPath )
{
parentPath . IsParentPath ( childPath ) . Should ( ) . Be ( true ) ;
}
[TestCase(@"C:\Test\mydir", @"C:\Test")]
@ -145,20 +150,57 @@ namespace NzbDrone.Common.Test
[TestCase(@"C:\", null)]
[TestCase(@"\\server\share", null)]
[TestCase(@"\\server\share\test", @"\\server\share")]
public void path_should_return_parent_windows ( string path , string parentPath )
public void windows_ path_should_return_parent( string path , string parentPath )
{
WindowsOnly ( ) ;
path . GetParentPath ( ) . Should ( ) . Be ( parentPath ) ;
}
[TestCase(@"/", null)]
[TestCase(@"/test", "/")]
public void path_should_return_parent_mono ( string path , string parentPath )
[TestCase(@"/test/tv", "/test")]
public void unix_path_should_return_parent ( string path , string parentPath )
{
PosixOnly ( ) ;
path . GetParentPath ( ) . Should ( ) . Be ( parentPath ) ;
}
[TestCase(@"C:\Test\mydir", "Test")]
[TestCase(@"C:\Test\", @"C:\")]
[TestCase(@"C:\Test", @"C:\")]
[TestCase(@"C:\", null)]
[TestCase(@"\\server\share", null)]
[TestCase(@"\\server\share\test", @"\\server\share")]
public void path_should_return_parent_name_windows ( string path , string parentPath )
{
path . GetParentName ( ) . Should ( ) . Be ( parentPath ) ;
}
[TestCase(@"/", null)]
[TestCase(@"/test", "/")]
[TestCase(@"/test/tv", "test")]
public void path_should_return_parent_name_mono ( string path , string parentPath )
{
path . GetParentName ( ) . Should ( ) . Be ( parentPath ) ;
}
[TestCase(@"C:\Test\mydir", "mydir")]
[TestCase(@"C:\Test\", "Test")]
[TestCase(@"C:\Test", "Test")]
[TestCase(@"C:\", "C:\\")]
[TestCase(@"\\server\share", @"\\server\share")]
[TestCase(@"\\server\share\test", "test")]
public void path_should_return_directory_name_windows ( string path , string parentPath )
{
path . GetDirectoryName ( ) . Should ( ) . Be ( parentPath ) ;
}
[TestCase(@"/", "/")]
[TestCase(@"/test", "test")]
[TestCase(@"/test/tv", "tv")]
public void path_should_return_directory_name_mono ( string path , string parentPath )
{
path . GetDirectoryName ( ) . Should ( ) . Be ( parentPath ) ;
}
[Test]
public void path_should_return_parent_for_oversized_path ( )
{
@ -166,7 +208,7 @@ namespace NzbDrone.Common.Test
// This test will fail on Windows if long path support is not enabled: https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
// It will also fail if the app isn't configured to use long path (such as resharper): https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/
var path = @"C:\media\2e168617-f2ae-43fb-b88c-3663af1c8eea\downloads\sabnzbd\nzbdrone\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories" . AsOsAgnostic ( ) ;
var path = @"C:\media\2e168617-f2ae-43fb-b88c-3663af1c8eea\downloads\sabnzbd\nzbdrone\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories" . AsOsAgnostic ( ) ;
var parentPath = @"C:\media\2e168617-f2ae-43fb-b88c-3663af1c8eea\downloads\sabnzbd\nzbdrone\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing\With.Alot.Of.Nested.Directories\Some.Real.Big.Thing" . AsOsAgnostic ( ) ;
path . GetParentPath ( ) . Should ( ) . Be ( parentPath ) ;