Merge branch 'develop' into dev/repin-monad

This commit is contained in:
Andrew Schwartzmeyer 2015-09-04 15:19:10 -07:00
commit 70914a35ac

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