Merge pull request 238 from dev/symlink into develop

Add tests for FQDN and SymLink
This commit is contained in:
George Fleming
2015-11-02 23:08:27 +00:00
+66
View File
@@ -90,6 +90,31 @@ namespace PSTests
}
}
[Fact]
public static void TestGetFQDN()
{
var startInfo = new ProcessStartInfo
{
FileName = @"/usr/bin/env",
Arguments = "hostname --fqdn",
RedirectStandardOutput = true,
UseShellExecute = false
};
using (Process process = Process.Start(startInfo))
{
// Get output of call to hostname without trailing newline
string hostname = process.StandardOutput.ReadToEnd().Trim();
process.WaitForExit();
// The process should return an exit code of 0 on success
Assert.Equal(0, process.ExitCode);
// It should be the same as what our platform code returns
Assert.Equal(hostname, Platform.NonWindowsGetHostName());
}
}
[Fact]
@@ -181,6 +206,47 @@ namespace PSTests
Assert.False(Platform.NonWindowsIsHardLink(fd));
}
[Fact]
public static void TestFileIsSymLink()
{
string path = @"/tmp/originallink";
if (File.Exists(path))
{
File.Delete(path);
}
File.Create(path);
string link = "/tmp/newlink";
if (File.Exists(link))
{
File.Delete(link);
}
var startInfo = new ProcessStartInfo
{
FileName = @"/usr/bin/env",
Arguments = "ln -s " + path + " " + link,
RedirectStandardOutput = true,
UseShellExecute = false
};
using (Process process = Process.Start(startInfo))
{
process.WaitForExit();
Assert.Equal(0, process.ExitCode);
}
FileSystemInfo fd = new FileInfo(path);
Assert.False(Platform.NonWindowsIsSymLink(fd));
fd = new FileInfo(link);
Assert.True(Platform.NonWindowsIsSymLink(fd));
File.Delete(path);
File.Delete(link);
}
[Fact]
public static void TestCommandLineArgvReturnsAnElement()