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
This commit is contained in:
Markus Ewald 2008-09-26 19:24:44 +00:00
parent b0e76b4800
commit 1cc45237ba
2 changed files with 74 additions and 8 deletions

View File

@ -37,7 +37,7 @@ namespace Nuclex.Support {
/// the location being passed is not relative to the base path. /// the location being passed is not relative to the base path.
/// </summary> /// </summary>
[Test] [Test]
public void TestRelativePathOfNonRelativePath() { public void TestRelativeWindowsPathOfNonRelativePath() {
Assert.That( Assert.That(
PathHelper.MakeRelative( PathHelper.MakeRelative(
platformify("C:/Folder1/Folder2"), platformify("C:/Folder1/Folder2"),
@ -57,10 +57,10 @@ namespace Nuclex.Support {
/// <summary> /// <summary>
/// Tests whether the relative path creator correctly builds the relative /// 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.
/// </summary> /// </summary>
[Test] [Test]
public void TestRelativePathToParentFolder() { public void TestRelativeWindowsPathToParentFolder() {
Assert.That( Assert.That(
PathHelper.MakeRelative( PathHelper.MakeRelative(
platformify("C:/Folder1/Folder2"), platformify("C:/Folder1/Folder2"),
@ -79,10 +79,32 @@ namespace Nuclex.Support {
/// <summary> /// <summary>
/// Tests whether the relative path creator correctly builds the relative /// 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.
/// </summary> /// </summary>
[Test] [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("../"))
);
}
/// <summary>
/// Tests whether the relative path creator correctly builds the relative
/// path to a nested folder in the base path for windows paths.
/// </summary>
[Test]
public void TestRelativeWindowsPathToNestedFolder() {
Assert.That( Assert.That(
PathHelper.MakeRelative( PathHelper.MakeRelative(
platformify("C:/Folder1"), platformify("C:/Folder1"),
@ -101,10 +123,32 @@ namespace Nuclex.Support {
/// <summary> /// <summary>
/// Tests whether the relative path creator correctly builds the relative /// 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.
/// </summary> /// </summary>
[Test] [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/"))
);
}
/// <summary>
/// Tests whether the relative path creator correctly builds the relative
/// path to another folder on the same level as base path for windows paths.
/// </summary>
[Test]
public void TestRelativeWindowsPathToSiblingFolder() {
Assert.That( Assert.That(
PathHelper.MakeRelative( PathHelper.MakeRelative(
platformify("C:/Folder1/Folder2/"), platformify("C:/Folder1/Folder2/"),
@ -121,6 +165,28 @@ namespace Nuclex.Support {
); );
} }
/// <summary>
/// Tests whether the relative path creator correctly builds the relative
/// path to another folder on the same level as base path for unix paths.
/// </summary>
[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"))
);
}
/// <summary> /// <summary>
/// Converts unix-style directory separators into the format used by the current platform /// Converts unix-style directory separators into the format used by the current platform
/// </summary> /// </summary>

View File

@ -28,7 +28,7 @@ namespace Nuclex.Support {
/// <summary> /// <summary>
/// Searches for the first occurence of a character other than the characters /// Searches for the first occurence of a character other than the characters
/// listed in the <<paramref name="anyNotOf" /> parameter /// listed in the <paramref name="anyNotOf" /> parameter
/// </summary> /// </summary>
/// <param name="haystack">String that will be scanned in</param> /// <param name="haystack">String that will be scanned in</param>
/// <param name="anyNotOf">Characters to not look for in the scanned string</param> /// <param name="anyNotOf">Characters to not look for in the scanned string</param>