Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct paramName in Path.GetRelativePath #1035

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: use correct paramName in Path.GetRelativePath
vbreuss committed Aug 25, 2023
commit 1e8b9be048fe7b4dd5aba83da48deda368ecd728
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ public override string GetRelativePath(string relativeTo, string path)
throw new ArgumentNullException(nameof(relativeTo), StringResources.Manager.GetString("VALUE_CANNOT_BE_NULL"));
}

if (relativeTo.Length == 0)
if (string.IsNullOrWhiteSpace(relativeTo))
{
throw CommonExceptions.PathIsNotOfALegalForm(nameof(relativeTo));
}
Original file line number Diff line number Diff line change
@@ -494,8 +494,6 @@ public void IsPathFullyQualified_WithRelativePathParts_ReturnsFalse()
Assert.IsFalse(result);
}



[Test]
public void GetRelativePath_Works()
{
@@ -508,6 +506,58 @@ public void GetRelativePath_Works()
//Assert
Assert.AreEqual(XFS.Path("e\\f.txt"), result);
}

[Test]
public void GetRelativePath_WhenPathIsNull_ShouldThrowArgumentNullException()
{
var mockPath = new MockFileSystem().Path;

var exception = Assert.Throws<ArgumentNullException>(() =>
{
mockPath.GetRelativePath("foo", null);
});

Assert.AreEqual("path", exception.ParamName);
}

[Test]
public void GetRelativePath_WhenPathIsWhitespace_ShouldThrowArgumentException()
{
var mockPath = new MockFileSystem().Path;

var exception = Assert.Throws<ArgumentException>(() =>
{
mockPath.GetRelativePath("foo", " ");
});

Assert.AreEqual("path", exception.ParamName);
}

[Test]
public void GetRelativePath_WhenRelativeToNull_ShouldThrowArgumentNullException()
{
var mockPath = new MockFileSystem().Path;

var exception = Assert.Throws<ArgumentNullException>(() =>
{
mockPath.GetRelativePath(null, "foo");
});

Assert.AreEqual("relativeTo", exception.ParamName);
}

[Test]
public void GetRelativePath_WhenRelativeToIsWhitespace_ShouldThrowArgumentException()
{
var mockPath = new MockFileSystem().Path;

var exception = Assert.Throws<ArgumentException>(() =>
{
mockPath.GetRelativePath(" ", "foo");
});

Assert.AreEqual("relativeTo", exception.ParamName);
}
#endif

#if FEATURE_PATH_EXISTS