diff --git a/src/ps_test/test_CorePsPlatform.cs b/src/ps_test/test_CorePsPlatform.cs index bc62134ca..a8bf60eb9 100644 --- a/src/ps_test/test_CorePsPlatform.cs +++ b/src/ps_test/test_CorePsPlatform.cs @@ -102,6 +102,7 @@ namespace PSTests { File.Create(path); } + // Create a file to write to using StreamWriter. // convert string to stream. On Windows, this appears to be handled, but on *nix, we apparently need to convert to UTF8. byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(path); @@ -123,16 +124,23 @@ namespace PSTests // A folder that should exist on every *nix system string path = @"/tmp"; - // Create a file to write to using StreamWriter. - // convert string to stream. On Windows, this appears to be handled, but on *nix, we apparently need to convert to UTF8. - byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(path); - MemoryStream stream = new MemoryStream(byteArray); + // Convert `path` string to FileSystemInfo data type. And now, it should return true + FileSystemInfo fd = new FileInfo(path); + Assert.False(Platform.NonWindowsIsHardLink(fd)); + } + + [Fact] + public static void TestIsHardLinkFailsWithNonexistantFileWithFileSystemInfo() + { + // A file that should *never* exist on a test machine: + string path = @"/tmp/ThisFileShouldNotExistOnTestMachines"; + + // If the file exists, then there's a larger issue that needs to be looked at + Assert.False(File.Exists(path)); // Convert `path` string to FileSystemInfo data type. And now, it should return true FileSystemInfo fd = new FileInfo(path); Assert.False(Platform.NonWindowsIsHardLink(fd)); - } - } }