Skip to content

Commit 50cccda

Browse files
committed
Expected input in capabilities
1 parent be8810a commit 50cccda

File tree

3 files changed

+337
-372
lines changed

3 files changed

+337
-372
lines changed

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,49 @@
33

44
@{
55

6-
# Script module or binary module file associated with this manifest.
7-
RootModule = 'TestClassResource.psm1'
6+
# Script module or binary module file associated with this manifest.
7+
RootModule = 'TestClassResource.psm1'
88

9-
# Version number of this module.
10-
ModuleVersion = '0.0.1'
9+
# Version number of this module.
10+
ModuleVersion = '0.0.1'
1111

12-
# ID used to uniquely identify this module
13-
GUID = 'b267fa32-e77d-48e6-9248-676cc6f2327f'
12+
# ID used to uniquely identify this module
13+
GUID = 'b267fa32-e77d-48e6-9248-676cc6f2327f'
1414

15-
# Author of this module
16-
Author = 'Microsoft'
15+
# Author of this module
16+
Author = 'Microsoft'
1717

18-
# Company or vendor of this module
19-
CompanyName = 'Microsoft Corporation'
18+
# Company or vendor of this module
19+
CompanyName = 'Microsoft Corporation'
2020

21-
# Copyright statement for this module
22-
Copyright = '(c) Microsoft. All rights reserved.'
21+
# Copyright statement for this module
22+
Copyright = '(c) Microsoft. All rights reserved.'
2323

24-
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
25-
FunctionsToExport = @()
24+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
25+
FunctionsToExport = @()
2626

27-
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
28-
CmdletsToExport = '*'
27+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
28+
CmdletsToExport = '*'
2929

30-
# Variables to export from this module
31-
VariablesToExport = @()
30+
# Variables to export from this module
31+
VariablesToExport = @()
3232

33-
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
34-
AliasesToExport = @()
33+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
34+
AliasesToExport = @()
3535

36-
# DSC resources to export from this module
37-
DscResourcesToExport = @('TestClassResource', 'NoExport')
36+
# DSC resources to export from this module
37+
DscResourcesToExport = @('TestClassResource', 'NoExport')
3838

39-
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
40-
PrivateData = @{
41-
PSData = @{
42-
DscCapabilities = @(
43-
'get'
44-
'test'
45-
'whatif'
46-
)
39+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
40+
PrivateData = @{
41+
PSData = @{
42+
DscCapabilities = @(
43+
'get'
44+
'test'
45+
'whatIf'
46+
'export'
47+
)
48+
}
4749
}
4850
}
4951

50-
}
51-

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

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ enum Ensure {
1313
Absent
1414
}
1515

16-
class BaseTestClass
17-
{
16+
class BaseTestClass {
1817
[DscProperty()]
1918
[string] $BaseProperty
2019
}
2120

2221
[DscResource()]
23-
class TestClassResource : BaseTestClass
24-
{
22+
class TestClassResource : BaseTestClass {
2523
[DscProperty(Key)]
2624
[string] $Name
2725

@@ -49,44 +47,36 @@ class TestClassResource : BaseTestClass
4947
[DscProperty()]
5048
[string] $HiddenDscProperty # This property should be in results data, but is an anti-pattern.
5149

52-
[void] Set()
53-
{
50+
[void] Set() {
5451
}
5552

56-
[bool] Test()
57-
{
58-
if (($this.Name -eq "TestClassResource1") -and ($this.Prop1 -eq "ValueForProp1"))
59-
{
53+
[bool] Test() {
54+
if (($this.Name -eq "TestClassResource1") -and ($this.Prop1 -eq "ValueForProp1")) {
6055
return $true
6156
}
62-
else
63-
{
57+
else {
6458
return $false
6559
}
6660
}
6761

68-
[TestClassResource] Get()
69-
{
70-
if ($this.Name -eq "TestClassResource1")
71-
{
62+
[TestClassResource] Get() {
63+
if ($this.Name -eq "TestClassResource1") {
7264
$this.Prop1 = "ValueForProp1"
7365
}
74-
else
75-
{
66+
else {
7667
$this.Prop1 = $env:DSC_CONFIG_ROOT
7768
}
7869
$this.EnumProp = ([EnumPropEnumeration]::Expected).ToString()
7970
return $this
8071
}
8172

82-
static [TestClassResource[]] Export()
83-
{
73+
static [TestClassResource[]] Export() {
8474
$resultList = [List[TestClassResource]]::new()
8575
$resultCount = 5
8676
if ($env:TestClassResourceResultCount) {
8777
$resultCount = $env:TestClassResourceResultCount
8878
}
89-
1..$resultCount | %{
79+
1..$resultCount | % {
9080
$obj = New-Object TestClassResource
9181
$obj.Name = "Object$_"
9282
$obj.Prop1 = "Property of object$_"
@@ -96,20 +86,17 @@ class TestClassResource : BaseTestClass
9686
return $resultList.ToArray()
9787
}
9888

99-
static [TestClassResource[]] Export([bool]$UseExport)
100-
{
101-
if ($UseExport)
102-
{
89+
static [TestClassResource[]] Export([bool]$UseExport) {
90+
if ($UseExport) {
10391
return [TestClassResource]::Export()
10492
}
105-
else
106-
{
93+
else {
10794
$resultList = [List[TestClassResource]]::new()
10895
$resultCount = 5
10996
if ($env:TestClassResourceResultCount) {
11097
$resultCount = $env:TestClassResourceResultCount
11198
}
112-
1..$resultCount | %{
99+
1..$resultCount | % {
113100
$obj = New-Object TestClassResource
114101
$obj.Name = "Object$_"
115102
$obj.Prop1 = "Property of object$_"
@@ -122,7 +109,7 @@ class TestClassResource : BaseTestClass
122109

123110
[string] WhatIf() {
124111
$out = @{
125-
Name = $this.Name
112+
Name = $this.Name
126113
_metadata = @{
127114
whatIf = "A test message from the WhatIf method of TestClassResource"
128115
}
@@ -133,8 +120,7 @@ class TestClassResource : BaseTestClass
133120
}
134121

135122
[DscResource()]
136-
class NoExport: BaseTestClass
137-
{
123+
class NoExport: BaseTestClass {
138124
[DscProperty(Key)]
139125
[string] $Name
140126

@@ -144,40 +130,19 @@ class NoExport: BaseTestClass
144130
[DscProperty()]
145131
[string] $EnumProp
146132

147-
[void] Set()
148-
{
133+
[void] Set() {
149134
}
150135

151-
[bool] Test()
152-
{
136+
[bool] Test() {
153137
return $true
154138
}
155139

156-
[NoExport] Get()
157-
{
140+
[NoExport] Get() {
158141
return $this
159142
}
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-
}
143+
}
178144

179145

180-
function Test-World()
181-
{
146+
function Test-World() {
182147
"Hello world from PSTestModule!"
183148
}

0 commit comments

Comments
 (0)