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)); }
[DataRow(false, @"C:\Program Files (x86)", @"C:\Program Files")] // not naive StartsWith public void TestIsSubfolderOfWindows(bool expectedIsSubfolder, string childPath, string parentPath) { PlatformTestUtils.OnlyRunOnWindows(); Assert.AreEqual(expectedIsSubfolder, childPath.IsSubfolderOf(parentPath)); }