diff --git a/Source/Testably.Abstractions.Testing/Helpers/Execute.NativePath.cs b/Source/Testably.Abstractions.Testing/Helpers/Execute.NativePath.cs index f5463a80..28ed3356 100644 --- a/Source/Testably.Abstractions.Testing/Helpers/Execute.NativePath.cs +++ b/Source/Testably.Abstractions.Testing/Helpers/Execute.NativePath.cs @@ -132,17 +132,15 @@ public string GetFullPath(string path) string? pathRoot = System.IO.Path.GetPathRoot(path); string? directoryRoot = System.IO.Path.GetPathRoot(fileSystem.Storage.CurrentDirectory); - if (!string.IsNullOrEmpty(pathRoot) && !string.IsNullOrEmpty(directoryRoot)) + if (pathRoot?.Length < directoryRoot?.Length) { - if (char.ToUpperInvariant(pathRoot[0]) != char.ToUpperInvariant(directoryRoot[0])) + if (pathRoot.Length > 0 && + char.ToUpperInvariant(pathRoot[0]) != char.ToUpperInvariant(directoryRoot[0])) { return System.IO.Path.GetFullPath(path); } - if (pathRoot.Length < directoryRoot.Length) - { - path = path.Substring(pathRoot.Length); - } + path = path.Substring(pathRoot.Length); } return System.IO.Path.GetFullPath(System.IO.Path.Combine( @@ -183,7 +181,6 @@ public string GetRandomFileName() public string GetRelativePath(string relativeTo, string path) { relativeTo.EnsureValidArgument(fileSystem, nameof(relativeTo)); - path.EnsureValidArgument(fileSystem, nameof(path)); relativeTo = fileSystem.Execute.Path.GetFullPath(relativeTo); path = fileSystem.Execute.Path.GetFullPath(path); diff --git a/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs b/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs index c81ac151..5242af70 100644 --- a/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs +++ b/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs @@ -290,7 +290,6 @@ public string GetRandomFileName() public string GetRelativePath(string relativeTo, string path) { relativeTo.EnsureValidArgument(fileSystem, nameof(relativeTo)); - path.EnsureValidArgument(fileSystem, nameof(path)); relativeTo = fileSystem.Execute.Path.GetFullPath(relativeTo); path = fileSystem.Execute.Path.GetFullPath(path); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs index 758e76da..b66b759c 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs @@ -44,7 +44,7 @@ public void GetPathRoot_ShouldReturnDefaultValue(string path) { string? result = FileSystem.Path.GetPathRoot(path); - result.Should().Be(System.IO.Path.GetPathRoot(path)); + result.Should().Be(""); } #if FEATURE_SPAN