Skip to content

Commit 0e9eb75

Browse files
committed
Add whatif capability
1 parent b7a8702 commit 0e9eb75

File tree

6 files changed

+478
-376
lines changed

6 files changed

+478
-376
lines changed

powershell-adapter/Tests/TestClassResource/0.0.1/TestClassResource.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ PrivateData = @{
4242
DscCapabilities = @(
4343
'get'
4444
'test'
45+
'whatif'
4546
)
4647
}
4748
}

powershell-adapter/Tests/TestClassResource/0.0.1/TestClassResource.psm1

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ class TestClassResource : BaseTestClass
119119

120120
return $resultList.ToArray()
121121
}
122+
123+
[string] WhatIf() {
124+
$out = @{
125+
Name = $this.Name
126+
_metadata = @{
127+
whatIIf = "A test message from the WhatIf method of TestClassResource"
128+
}
129+
}
130+
131+
return ($out | ConvertTo-Json -Depth 10 -Compress)
132+
}
122133
}
123134

124135
[DscResource()]
@@ -146,7 +157,25 @@ class NoExport: BaseTestClass
146157
{
147158
return $this
148159
}
149-
}
160+
161+
static [NoExport[]] Export()
162+
{
163+
$resultList = [List[NoExport]]::new()
164+
$resultCount = 5
165+
if ($env:TestClassResourceResultCount) {
166+
$resultCount = $env:TestClassResourceResultCount
167+
}
168+
1..$resultCount | %{
169+
$obj = New-Object NoExport
170+
$obj.Name = "Object$_"
171+
$obj.Prop1 = "Property of object$_"
172+
$resultList.Add($obj)
173+
}
174+
175+
return $resultList.ToArray()
176+
}
177+
}
178+
150179

151180
function Test-World()
152181
{

0 commit comments

Comments
 (0)