Add tests for FQDN and SymLink
This commit is contained in:
parent
eb05ca2e4e
commit
af52de746b
1 changed files with 66 additions and 0 deletions
|
@ -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]
|
[Fact]
|
||||||
|
@ -181,6 +206,47 @@ namespace PSTests
|
||||||
Assert.False(Platform.NonWindowsIsHardLink(fd));
|
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]
|
[Fact]
|
||||||
public static void TestCommandLineArgvReturnsAnElement()
|
public static void TestCommandLineArgvReturnsAnElement()
|
||||||
|
|
Loading…
Reference in a new issue