Skip to content
This repository was archived by the owner on Mar 11, 2020. It is now read-only.

Commit 3f552e9

Browse files
committed
added pester tests - fixes #20
Misc small updates Small update to Dockerfile template Added force paramater 1st lot of tests Corrected Path for Invoke-Pester fixed issue with psm1 file
1 parent dbe0f2a commit 3f552e9

File tree

80 files changed

+2450
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2450
-74
lines changed

Functions/Private/Artifacts/AddRemovePrograms/Discover_AddRemovePrograms.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The path where the Windows image was mounted to.
99
.PARAMETER OutputPath
1010
The filesystem path where the discovery manifest will be emitted.
1111
#>
12+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess",'')]
1213
[CmdletBinding()]
1314
param (
1415
[Parameter(Mandatory = $true)]

Functions/Private/Artifacts/AddRemovePrograms/Tests/Discover_AddRemovePrograms.Functional.Tests.ps1

Whitespace-only changes.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Describe 'Discover_AddRemovePrograms Tests' {
2+
3+
Context 'Parameters for Discover_AddRemovePrograms'{
4+
5+
It 'Has a Parameter called MountPath' {
6+
$Function.Parameters.Keys.Contains('MountPath') | Should Be 'True'
7+
}
8+
It 'MountPath Parameter is Identified as Mandatory being True' {
9+
[String]$Function.Parameters.MountPath.Attributes.Mandatory | Should be 'True'
10+
}
11+
It 'MountPath Parameter is of String Type' {
12+
$Function.Parameters.MountPath.ParameterType.FullName | Should be 'System.String'
13+
}
14+
It 'MountPath Parameter is member of ParameterSets' {
15+
[String]$Function.Parameters.MountPath.ParameterSets.Keys | Should Be '__AllParameterSets'
16+
}
17+
It 'MountPath Parameter Position is defined correctly' {
18+
[String]$Function.Parameters.MountPath.Attributes.Position | Should be '0'
19+
}
20+
It 'Does MountPath Parameter Accept Pipeline Input?' {
21+
[String]$Function.Parameters.MountPath.Attributes.ValueFromPipeline | Should be 'False'
22+
}
23+
It 'Does MountPath Parameter Accept Pipeline Input by PropertyName?' {
24+
[String]$Function.Parameters.MountPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
25+
}
26+
It 'Does MountPath Parameter use advanced parameter Validation? ' {
27+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
28+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
29+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
30+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
31+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
32+
}
33+
It 'Has Parameter Help Text for MountPath '{
34+
$function.Definition.Contains('.PARAMETER MountPath') | Should Be 'True'
35+
}
36+
It 'Has a Parameter called OutputPath' {
37+
$Function.Parameters.Keys.Contains('OutputPath') | Should Be 'True'
38+
}
39+
It 'OutputPath Parameter is Identified as Mandatory being True' {
40+
[String]$Function.Parameters.OutputPath.Attributes.Mandatory | Should be 'True'
41+
}
42+
It 'OutputPath Parameter is of String Type' {
43+
$Function.Parameters.OutputPath.ParameterType.FullName | Should be 'System.String'
44+
}
45+
It 'OutputPath Parameter is member of ParameterSets' {
46+
[String]$Function.Parameters.OutputPath.ParameterSets.Keys | Should Be '__AllParameterSets'
47+
}
48+
It 'OutputPath Parameter Position is defined correctly' {
49+
[String]$Function.Parameters.OutputPath.Attributes.Position | Should be '1'
50+
}
51+
It 'Does OutputPath Parameter Accept Pipeline Input?' {
52+
[String]$Function.Parameters.OutputPath.Attributes.ValueFromPipeline | Should be 'False'
53+
}
54+
It 'Does OutputPath Parameter Accept Pipeline Input by PropertyName?' {
55+
[String]$Function.Parameters.OutputPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
56+
}
57+
It 'Does OutputPath Parameter use advanced parameter Validation? ' {
58+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
59+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
60+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
61+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
62+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
63+
}
64+
It 'Has Parameter Help Text for OutputPath '{
65+
$function.Definition.Contains('.PARAMETER OutputPath') | Should Be 'True'
66+
}
67+
}
68+
Context "Function $($function.Name) - Help Section" {
69+
70+
It "Function $($function.Name) Has show-help comment block" {
71+
72+
$function.Definition.Contains('<#') | should be 'True'
73+
$function.Definition.Contains('#>') | should be 'True'
74+
}
75+
76+
It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" {
77+
78+
$function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True'
79+
80+
}
81+
82+
It "Function $($function.Name) Is an advanced function" {
83+
84+
$function.CmdletBinding | should be 'True'
85+
$function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True'
86+
}
87+
88+
}
89+
90+
}
91+
92+

Functions/Private/Artifacts/AddRemovePrograms/Tests/Generate_AddRemovePrograms.Functional.Tests.ps1

Whitespace-only changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Describe 'Generate_AddRemovePrograms Tests' {
2+
3+
Context 'Parameters for Generate_AddRemovePrograms'{
4+
5+
It 'Has a Parameter called ManifestPath' {
6+
$Function.Parameters.Keys.Contains('ManifestPath') | Should Be 'True'
7+
}
8+
It 'ManifestPath Parameter is Identified as Mandatory being True' {
9+
[String]$Function.Parameters.ManifestPath.Attributes.Mandatory | Should be 'True'
10+
}
11+
It 'ManifestPath Parameter is of String Type' {
12+
$Function.Parameters.ManifestPath.ParameterType.FullName | Should be 'System.String'
13+
}
14+
It 'ManifestPath Parameter is member of ParameterSets' {
15+
[String]$Function.Parameters.ManifestPath.ParameterSets.Keys | Should Be '__AllParameterSets'
16+
}
17+
It 'ManifestPath Parameter Position is defined correctly' {
18+
[String]$Function.Parameters.ManifestPath.Attributes.Position | Should be '0'
19+
}
20+
It 'Does ManifestPath Parameter Accept Pipeline Input?' {
21+
[String]$Function.Parameters.ManifestPath.Attributes.ValueFromPipeline | Should be 'False'
22+
}
23+
It 'Does ManifestPath Parameter Accept Pipeline Input by PropertyName?' {
24+
[String]$Function.Parameters.ManifestPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
25+
}
26+
It 'Does ManifestPath Parameter use advanced parameter Validation? ' {
27+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
28+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
29+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
30+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
31+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
32+
}
33+
It 'Has Parameter Help Text for ManifestPath '{
34+
$function.Definition.Contains('.PARAMETER ManifestPath') | Should Be 'True'
35+
}
36+
}
37+
Context "Function $($function.Name) - Help Section" {
38+
39+
It "Function $($function.Name) Has show-help comment block" {
40+
41+
$function.Definition.Contains('<#') | should be 'True'
42+
$function.Definition.Contains('#>') | should be 'True'
43+
}
44+
45+
It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" {
46+
47+
$function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True'
48+
49+
}
50+
51+
It "Function $($function.Name) Is an advanced function" {
52+
53+
$function.CmdletBinding | should be 'True'
54+
$function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True'
55+
}
56+
57+
}
58+
59+
}
60+
61+

Functions/Private/Artifacts/AllWindowsFeatures/Discover_AllWindowsFeatures.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The path where the Windows image was mounted to.
99
.PARAMETER OutputPath
1010
The filesystem path where the discovery manifest will be emitted.
1111
#>
12+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess",'')]
1213
[CmdletBinding()]
1314
param (
1415
[Parameter(Mandatory = $true)]

Functions/Private/Artifacts/AllWindowsFeatures/Tests/Discover_AllWindowsFeatures.Functional.Tests.ps1

Whitespace-only changes.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Describe 'Discover_AllWindowsFeatures Tests' {
2+
3+
Context 'Parameters for Discover_AllWindowsFeatures'{
4+
5+
It 'Has a Parameter called MountPath' {
6+
$Function.Parameters.Keys.Contains('MountPath') | Should Be 'True'
7+
}
8+
It 'MountPath Parameter is Identified as Mandatory being True' {
9+
[String]$Function.Parameters.MountPath.Attributes.Mandatory | Should be 'True'
10+
}
11+
It 'MountPath Parameter is of String Type' {
12+
$Function.Parameters.MountPath.ParameterType.FullName | Should be 'System.String'
13+
}
14+
It 'MountPath Parameter is member of ParameterSets' {
15+
[String]$Function.Parameters.MountPath.ParameterSets.Keys | Should Be '__AllParameterSets'
16+
}
17+
It 'MountPath Parameter Position is defined correctly' {
18+
[String]$Function.Parameters.MountPath.Attributes.Position | Should be '0'
19+
}
20+
It 'Does MountPath Parameter Accept Pipeline Input?' {
21+
[String]$Function.Parameters.MountPath.Attributes.ValueFromPipeline | Should be 'False'
22+
}
23+
It 'Does MountPath Parameter Accept Pipeline Input by PropertyName?' {
24+
[String]$Function.Parameters.MountPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
25+
}
26+
It 'Does MountPath Parameter use advanced parameter Validation? ' {
27+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
28+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
29+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
30+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
31+
$Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
32+
}
33+
It 'Has Parameter Help Text for MountPath '{
34+
$function.Definition.Contains('.PARAMETER MountPath') | Should Be 'True'
35+
}
36+
It 'Has a Parameter called OutputPath' {
37+
$Function.Parameters.Keys.Contains('OutputPath') | Should Be 'True'
38+
}
39+
It 'OutputPath Parameter is Identified as Mandatory being True' {
40+
[String]$Function.Parameters.OutputPath.Attributes.Mandatory | Should be 'True'
41+
}
42+
It 'OutputPath Parameter is of String Type' {
43+
$Function.Parameters.OutputPath.ParameterType.FullName | Should be 'System.String'
44+
}
45+
It 'OutputPath Parameter is member of ParameterSets' {
46+
[String]$Function.Parameters.OutputPath.ParameterSets.Keys | Should Be '__AllParameterSets'
47+
}
48+
It 'OutputPath Parameter Position is defined correctly' {
49+
[String]$Function.Parameters.OutputPath.Attributes.Position | Should be '1'
50+
}
51+
It 'Does OutputPath Parameter Accept Pipeline Input?' {
52+
[String]$Function.Parameters.OutputPath.Attributes.ValueFromPipeline | Should be 'False'
53+
}
54+
It 'Does OutputPath Parameter Accept Pipeline Input by PropertyName?' {
55+
[String]$Function.Parameters.OutputPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
56+
}
57+
It 'Does OutputPath Parameter use advanced parameter Validation? ' {
58+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
59+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
60+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
61+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
62+
$Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
63+
}
64+
It 'Has Parameter Help Text for OutputPath '{
65+
$function.Definition.Contains('.PARAMETER OutputPath') | Should Be 'True'
66+
}
67+
}
68+
Context "Function $($function.Name) - Help Section" {
69+
70+
It "Function $($function.Name) Has show-help comment block" {
71+
72+
$function.Definition.Contains('<#') | should be 'True'
73+
$function.Definition.Contains('#>') | should be 'True'
74+
}
75+
76+
It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" {
77+
78+
$function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True'
79+
80+
}
81+
82+
It "Function $($function.Name) Is an advanced function" {
83+
84+
$function.CmdletBinding | should be 'True'
85+
$function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True'
86+
}
87+
88+
}
89+
90+
}
91+
92+

Functions/Private/Artifacts/AllWindowsFeatures/Tests/Generate_AllWindowsFeatures.Functional.Tests.ps1

Whitespace-only changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Describe 'Generate_AllWindowsFeatures Tests' {
2+
3+
Context 'Parameters for Generate_AllWindowsFeatures'{
4+
5+
It 'Has a Parameter called ManifestPath' {
6+
$Function.Parameters.Keys.Contains('ManifestPath') | Should Be 'True'
7+
}
8+
It 'ManifestPath Parameter is Identified as Mandatory being True' {
9+
[String]$Function.Parameters.ManifestPath.Attributes.Mandatory | Should be 'True'
10+
}
11+
It 'ManifestPath Parameter is of String Type' {
12+
$Function.Parameters.ManifestPath.ParameterType.FullName | Should be 'System.String'
13+
}
14+
It 'ManifestPath Parameter is member of ParameterSets' {
15+
[String]$Function.Parameters.ManifestPath.ParameterSets.Keys | Should Be '__AllParameterSets'
16+
}
17+
It 'ManifestPath Parameter Position is defined correctly' {
18+
[String]$Function.Parameters.ManifestPath.Attributes.Position | Should be '0'
19+
}
20+
It 'Does ManifestPath Parameter Accept Pipeline Input?' {
21+
[String]$Function.Parameters.ManifestPath.Attributes.ValueFromPipeline | Should be 'False'
22+
}
23+
It 'Does ManifestPath Parameter Accept Pipeline Input by PropertyName?' {
24+
[String]$Function.Parameters.ManifestPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
25+
}
26+
It 'Does ManifestPath Parameter use advanced parameter Validation? ' {
27+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
28+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
29+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
30+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
31+
$Function.Parameters.ManifestPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
32+
}
33+
It 'Has Parameter Help Text for ManifestPath '{
34+
$function.Definition.Contains('.PARAMETER ManifestPath') | Should Be 'True'
35+
}
36+
}
37+
Context "Function $($function.Name) - Help Section" {
38+
39+
It "Function $($function.Name) Has show-help comment block" {
40+
41+
$function.Definition.Contains('<#') | should be 'True'
42+
$function.Definition.Contains('#>') | should be 'True'
43+
}
44+
45+
It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" {
46+
47+
$function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True'
48+
49+
}
50+
51+
It "Function $($function.Name) Is an advanced function" {
52+
53+
$function.CmdletBinding | should be 'True'
54+
$function.Definition.Contains('param') -or $function.Definition.Contains('Param') | should be 'True'
55+
}
56+
57+
}
58+
59+
}
60+
61+

0 commit comments

Comments
 (0)