Change exception throwing in Path.GetRelativePath (dotnet/corefx#38388)
authorRoman Marusyk <Marusyk@users.noreply.github.com>
Fri, 2 Aug 2019 21:55:38 +0000 (00:55 +0300)
committerDan Moseley <danmose@microsoft.com>
Fri, 2 Aug 2019 21:55:38 +0000 (14:55 -0700)
* Fix Path.GetRelativePath throws ArgumentNullException when relativeTo is empty string

* Code review fixes

Commit migrated from https://github.com/dotnet/corefx/commit/249b5122a33ea08d2d00581ed691642c18ce1448

src/libraries/System.Runtime.Extensions/tests/System/IO/Path.GetRelativePath.cs

index 3f48bfd..7c3f431 100644 (file)
@@ -148,5 +148,12 @@ namespace System.IO.Tests
                 ignoreLineEndingDifferences: false,
                 ignoreWhiteSpaceDifferences: false);
         }
+
+        [Fact]
+        public static void GetRelativePath_InvalidArgs()
+        {
+            AssertExtensions.Throws<ArgumentNullException>("relativeTo", null, () => Path.GetRelativePath(null, "."));
+            AssertExtensions.Throws<ArgumentException>("relativeTo", null, () => Path.GetRelativePath(string.Empty, "."));
+        }
     }
 }