forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_HostingBasic.cs
More file actions
55 lines (48 loc) · 1.64 KB
/
test_HostingBasic.cs
File metadata and controls
55 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Xunit;
using System;
using System.Management.Automation;
namespace PowerShell.Hosting.SDK.Tests
{
public static class HostingTests
{
[Fact]
public static void TestCommandFromUtility()
{
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
var results = ps.AddScript("Get-Verb -Verb get").Invoke();
foreach (dynamic item in results)
{
Assert.Equal("Get", item.Verb);
}
}
}
[Fact]
public static void TestCommandFromManagement()
{
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
var path = Environment.CurrentDirectory;
var results = ps.AddCommand("Test-Path").AddParameter("Path", path).Invoke<bool>();
foreach (dynamic item in results)
{
Assert.True(item);
}
}
}
[Fact]
public static void TestCommandFromCore()
{
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
var results = ps.AddScript(@"$i = 0 ; 1..3 | ForEach-Object { $i += $_} ; $i").Invoke<int>();
foreach (dynamic item in results)
{
Assert.Equal(6,item);
}
}
}
}
}