Merge pull request 137 from dev/158-ishardlink-xunit into develop

This commit is contained in:
Zach Folwick 2015-09-03 23:48:41 +00:00
commit 64655b7085
2 changed files with 45 additions and 1 deletions

@ -1 +1 @@
Subproject commit d541b073435e55fd96771697e5549cc9a188fa54
Subproject commit d0697c432c1d678e59af3ebd6320e5bc3a432b2f

View file

@ -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));
}
}
}