@@ -268,4 +268,69 @@ resources:
268
268
$out | Should -Not - BeNullOrEmpty
269
269
$out | Should - BeLike " *ERROR*Credential object 'Credential' requires both 'username' and 'password' properties*"
270
270
}
271
+
272
+ It ' List works with class-based DSC resources' - Skip:(! $IsWindows ) {
273
+ BeforeDiscovery {
274
+ $windowsPowerShellPath = Join-Path $env: SystemRoot ' System32' ' WindowsPowerShell' ' v1.0' ' Modules'
275
+
276
+ $moduleFile = @"
277
+ @{
278
+ RootModule = 'PSClassResource.psm1'
279
+ ModuleVersion = '0.1.0'
280
+ GUID = '1b2e177b-1819-4f51-8bc9-795dd8fae984'
281
+ Author = 'Microsoft Corporation'
282
+ CompanyName = 'Microsoft Corporation'
283
+ Copyright = '(c) Microsoft Corporation. All rights reserved.'
284
+ Description = 'DSC Resource for Windows PowerShell Class'
285
+ PowerShellVersion = '5.1'
286
+ DscResourcesToExport = @(
287
+ 'PSClassResource'
288
+ )
289
+ PrivateData = @{
290
+ PSData = @{
291
+ Tags = @(
292
+ 'PSDscResource_PSClassResource'
293
+ )
294
+ }
295
+ }
296
+ }
297
+ "@
298
+ $moduleFilePath = Join-Path $windowsPowerShellPath ' PSClassResource' ' 0.1.0' ' PSClassResource.psd1'
299
+ if (-not (Test-Path - Path $moduleFilePath )) {
300
+ New-Item - Path $moduleFilePath - ItemType File - Value $moduleFile - Force | Out-Null
301
+ }
302
+
303
+
304
+ $module = @'
305
+ [DSCResource()]
306
+ class PSClassResource {
307
+ [DscProperty(Key)]
308
+ [string] $Name
309
+
310
+ PSClassResource() {
311
+ }
312
+
313
+ [PSClassResource] Get() {
314
+ return $this
315
+ }
316
+
317
+ [bool] Test() {
318
+ return $true
319
+ }
320
+
321
+ [void] Set() {
322
+
323
+ }
271
324
}
325
+ '@
326
+
327
+ $modulePath = Join-Path $windowsPowerShellPath ' PSClassResource' ' 0.1.0' ' PSClassResource.psm1'
328
+ if (-not (Test-Path - Path $modulePath )) {
329
+ New-Item - Path $modulePath - ItemType File - Value $module - Force | Out-Null
330
+ }
331
+ }
332
+
333
+ $resources = dsc - l trace resource list -- adapter Microsoft.Windows/ WindowsPowerShell | ConvertFrom-Json
334
+ $resources.type | Should - Contain ' PSClassResource/PSClassResource'
335
+ }
336
+ }
0 commit comments