From 1cc45237baae95697bf91856aa279f614ac08d7c Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Fri, 26 Sep 2008 19:24:44 +0000 Subject: [PATCH] Fixed error in XML comment; added some more unit tests for the PathHelper class to make sure it works with Linux/Unix paths git-svn-id: file:///srv/devel/repo-conversion/nusu@91 d2e56fa2-650e-0410-a79f-9358c0239efd --- Source/PathHelper.Test.cs | 80 +++++++++++++++++++++++++++++++++++---- Source/StringHelper.cs | 2 +- 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/Source/PathHelper.Test.cs b/Source/PathHelper.Test.cs index b20b369..4d4e335 100644 --- a/Source/PathHelper.Test.cs +++ b/Source/PathHelper.Test.cs @@ -37,7 +37,7 @@ namespace Nuclex.Support { /// the location being passed is not relative to the base path. /// [Test] - public void TestRelativePathOfNonRelativePath() { + public void TestRelativeWindowsPathOfNonRelativePath() { Assert.That( PathHelper.MakeRelative( platformify("C:/Folder1/Folder2"), @@ -57,10 +57,10 @@ namespace Nuclex.Support { /// /// Tests whether the relative path creator correctly builds the relative - /// path to the parent folder of the base path. + /// path to the parent folder of the base path for windows paths. /// [Test] - public void TestRelativePathToParentFolder() { + public void TestRelativeWindowsPathToParentFolder() { Assert.That( PathHelper.MakeRelative( platformify("C:/Folder1/Folder2"), @@ -79,10 +79,32 @@ namespace Nuclex.Support { /// /// Tests whether the relative path creator correctly builds the relative - /// path to a nested folder in the base path. + /// path to the parent folder of the base path for unix paths. /// [Test] - public void TestRelativePathToNestedFolder() { + public void TestRelativeUnixPathToParentFolder() { + Assert.That( + PathHelper.MakeRelative( + platformify("/Folder1/Folder2"), + platformify("/Folder1") + ), + Is.EqualTo(platformify("..")) + ); + Assert.That( + PathHelper.MakeRelative( + platformify("/Folder1/Folder2/"), + platformify("/Folder1/") + ), + Is.EqualTo(platformify("../")) + ); + } + + /// + /// Tests whether the relative path creator correctly builds the relative + /// path to a nested folder in the base path for windows paths. + /// + [Test] + public void TestRelativeWindowsPathToNestedFolder() { Assert.That( PathHelper.MakeRelative( platformify("C:/Folder1"), @@ -101,10 +123,32 @@ namespace Nuclex.Support { /// /// Tests whether the relative path creator correctly builds the relative - /// path to another folder on the same level as base path. + /// path to a nested folder in the base path for unix paths. /// [Test] - public void TestRelativePathToSiblingFolder() { + public void TestRelativeUnixPathToNestedFolder() { + Assert.That( + PathHelper.MakeRelative( + platformify("/Folder1"), + platformify("/Folder1/Folder2") + ), + Is.EqualTo(platformify("Folder2")) + ); + Assert.That( + PathHelper.MakeRelative( + platformify("/Folder1/"), + platformify("/Folder1/Folder2/") + ), + Is.EqualTo(platformify("Folder2/")) + ); + } + + /// + /// Tests whether the relative path creator correctly builds the relative + /// path to another folder on the same level as base path for windows paths. + /// + [Test] + public void TestRelativeWindowsPathToSiblingFolder() { Assert.That( PathHelper.MakeRelative( platformify("C:/Folder1/Folder2/"), @@ -121,6 +165,28 @@ namespace Nuclex.Support { ); } + /// + /// Tests whether the relative path creator correctly builds the relative + /// path to another folder on the same level as base path for unix paths. + /// + [Test] + public void TestRelativeUnixPathToSiblingFolder() { + Assert.That( + PathHelper.MakeRelative( + platformify("/Folder1/Folder2/"), + platformify("/Folder1/Folder2345") + ), + Is.EqualTo(platformify("../Folder2345")) + ); + Assert.That( + PathHelper.MakeRelative( + platformify("/Folder1/Folder2345/"), + platformify("/Folder1/Folder2") + ), + Is.EqualTo(platformify("../Folder2")) + ); + } + /// /// Converts unix-style directory separators into the format used by the current platform /// diff --git a/Source/StringHelper.cs b/Source/StringHelper.cs index f0aaca5..baa3160 100644 --- a/Source/StringHelper.cs +++ b/Source/StringHelper.cs @@ -28,7 +28,7 @@ namespace Nuclex.Support { /// /// Searches for the first occurence of a character other than the characters - /// listed in the < parameter + /// listed in the parameter /// /// String that will be scanned in /// Characters to not look for in the scanned string