mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
- Pester source code moved to `test/Pester`, deleted `ext-src`. - Pester tests (.ps1 files) moved to `test/powershell` - xUnit tests (.cs files) moved to `test/csharp` - Third-party script test moved to `test/shebang`
72 lines
2.1 KiB
C#
72 lines
2.1 KiB
C#
using Xunit;
|
|
using System;
|
|
using System.Management.Automation;
|
|
using System.Diagnostics;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Xml.Linq;
|
|
|
|
namespace PSTests
|
|
{
|
|
public static class OmiInterfaceTests
|
|
{
|
|
[Fact]
|
|
public static void TestHostName()
|
|
{
|
|
const string ns = "root/omi";
|
|
const string cn = "OMI_Identify";
|
|
const string property = "SystemName";
|
|
|
|
string expected = null;
|
|
|
|
var startInfo = new ProcessStartInfo
|
|
{
|
|
FileName = @"/usr/bin/env",
|
|
Arguments = "hostname",
|
|
RedirectStandardOutput = true,
|
|
UseShellExecute = false
|
|
};
|
|
using (Process process = Process.Start(startInfo))
|
|
{
|
|
// Get output of call to hostname without trailing newline
|
|
expected = process.StandardOutput.ReadToEnd().Trim();
|
|
process.WaitForExit();
|
|
|
|
// The process should return an exit code of 0 on success
|
|
Assert.Equal(0, process.ExitCode);
|
|
}
|
|
|
|
string value = null;
|
|
OmiInterface oi = new OmiInterface();
|
|
oi.GetOmiValue(ns, cn, property, out value);
|
|
Assert.Equal(expected, value);
|
|
}
|
|
|
|
[Fact]
|
|
public static void TestXHugeNumberEnumerable()
|
|
{
|
|
const string ns = "interop";
|
|
const string cn = "X_HugeNumber";
|
|
|
|
OmiInterface oi = new OmiInterface();
|
|
IEnumerable<XElement> elements;
|
|
oi.GetOmiValues(ns, cn, out elements);
|
|
Assert.True(elements.FirstOrDefault() != null);
|
|
}
|
|
|
|
[Fact]
|
|
public static void TestXHugeNumberOmiData()
|
|
{
|
|
const string ns = "interop";
|
|
const string cn = "X_HugeNumber";
|
|
|
|
OmiInterface oi = new OmiInterface();
|
|
|
|
OmiData data;
|
|
oi.GetOmiValues(ns, cn, out data);
|
|
Assert.True(data != null);
|
|
Assert.Equal(data.Values.Count(), 22);
|
|
}
|
|
}
|
|
}
|