diff --git a/src/monad b/src/monad index d541b0734..d0697c432 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit d541b073435e55fd96771697e5549cc9a188fa54 +Subproject commit d0697c432c1d678e59af3ebd6320e5bc3a432b2f diff --git a/src/ps_test/test_CorePsPlatform.cs b/src/ps_test/test_CorePsPlatform.cs index 57e58bc32..e11826091 100644 --- a/src/ps_test/test_CorePsPlatform.cs +++ b/src/ps_test/test_CorePsPlatform.cs @@ -1,5 +1,6 @@ using Xunit; using System; +using System.IO; using System.Diagnostics; using System.Management.Automation; @@ -90,5 +91,48 @@ namespace PSTests } + + [Fact] + public static void TestExistantFileIsHardLink() + { + string path = @"/tmp/MyTest"; + if (!File.Exists(path)) + { + 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); + MemoryStream stream = new MemoryStream(byteArray); + + // Convert `path` string to FileSystemInfo data type. And now, it should return true + FileSystemInfo fd = new FileInfo(path); + Assert.True(Platform.NonWindowsIsHardLink(fd)); + } + + [Fact] + public static void TestDirectoryIsHardLink() + { + string path = @"/tmp"; + + // 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 TestNonExistantIsHardLink() + { + // 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)); + } } }