added unit test for additional failure cases and removed unneeded code from existing unit tests

This commit is contained in:
Zachary Folwick 2015-09-02 11:15:31 -07:00
parent 080c734dfb
commit 9b02eea58d

View file

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