public void TestGetRelativeWindows(string expectedRelPath, bool isChild, string absolutePath, string basePath) { PlatformTestUtils.OnlyRunOnWindows(); Assert.AreEqual(expectedRelPath, PE.GetRelativePath(fromPath: basePath, toPath: absolutePath)); // params swapped w.r.t. `MakeRelativeTo` // `MakeRelativeTo` is supposed to return an absolute path (the receiver is assumed to be absolute) iff the receiver isn't a child of the given base path Assert.AreEqual(isChild ? expectedRelPath : absolutePath, absolutePath.MakeRelativeTo(basePath)); }
public void TestNullability() { PlatformTestUtils.RunEverywhere(); var p = OSTailoredCode.IsUnixHost ? "/" : @"C:\"; Assert.IsFalse(PE.IsSubfolderOf(childPath: null, parentPath: p)); Assert.IsFalse(PE.IsSubfolderOf(childPath: p, parentPath: null)); Assert.IsFalse(PE.IsSubfolderOf(childPath: null, parentPath: null)); Assert.IsNull(PE.GetRelativePath(fromPath: null, toPath: p)); Assert.IsNull(PE.GetRelativePath(fromPath: p, toPath: null)); Assert.IsNull(PE.GetRelativePath(fromPath: null, toPath: null)); Assert.IsNull(PE.MakeRelativeTo(absolutePath: null, basePath: p)); Assert.IsNull(PE.MakeRelativeTo(absolutePath: p, basePath: null)); Assert.IsNull(PE.MakeRelativeTo(absolutePath: null, basePath: null)); }