Functions/Public/ConvertTo/Tests/ConvertTo-Dockerfile.Tests.ps1

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
Describe 'ConvertTo-Dockerfile Tests' {

   Context 'Parameters for ConvertTo-Dockerfile'{

        It 'Has a Parameter called ImagePath' {
            $Function.Parameters.Keys.Contains('ImagePath') | Should Be 'True'
            }
        It 'ImagePath Parameter is Identified as Mandatory being True' {
            [String]$Function.Parameters.ImagePath.Attributes.Mandatory | Should be 'True'
            }
        It 'ImagePath Parameter is of String Type' {
            $Function.Parameters.ImagePath.ParameterType.FullName | Should be 'System.String'
            }
        It 'ImagePath Parameter is member of ParameterSets' {
            [String]$Function.Parameters.ImagePath.ParameterSets.Keys | Should Be '__AllParameterSets'
            }
        It 'ImagePath Parameter Position is defined correctly' {
            [String]$Function.Parameters.ImagePath.Attributes.Position | Should be '0'
            }
        It 'Does ImagePath Parameter Accept Pipeline Input?' {
            [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipeline | Should be 'False'
            }
        It 'Does ImagePath Parameter Accept Pipeline Input by PropertyName?' {
            [String]$Function.Parameters.ImagePath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
            }
        It 'Does ImagePath Parameter use advanced parameter Validation? ' {
            $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
            $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
            $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
            $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
            $Function.Parameters.ImagePath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
            }
        It 'Has Parameter Help Text for ImagePath '{
            $function.Definition.Contains('.PARAMETER ImagePath') | Should Be 'True'
            }
        It 'Has a Parameter called OutputPath' {
            $Function.Parameters.Keys.Contains('OutputPath') | Should Be 'True'
            }
        It 'OutputPath Parameter is Identified as Mandatory being False' {
            [String]$Function.Parameters.OutputPath.Attributes.Mandatory | Should be 'False'
            }
        It 'OutputPath Parameter is of String Type' {
            $Function.Parameters.OutputPath.ParameterType.FullName | Should be 'System.String'
            }
        It 'OutputPath Parameter is member of ParameterSets' {
            [String]$Function.Parameters.OutputPath.ParameterSets.Keys | Should Be '__AllParameterSets'
            }
        It 'OutputPath Parameter Position is defined correctly' {
            [String]$Function.Parameters.OutputPath.Attributes.Position | Should be '1'
            }
        It 'Does OutputPath Parameter Accept Pipeline Input?' {
            [String]$Function.Parameters.OutputPath.Attributes.ValueFromPipeline | Should be 'False'
            }
        It 'Does OutputPath Parameter Accept Pipeline Input by PropertyName?' {
            [String]$Function.Parameters.OutputPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
            }
        It 'Does OutputPath Parameter use advanced parameter Validation? ' {
            $Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
            $Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
            $Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
            $Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
            $Function.Parameters.OutputPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
            }
        It 'Has Parameter Help Text for OutputPath '{
            $function.Definition.Contains('.PARAMETER OutputPath') | Should Be 'True'
            }
        It 'Has a Parameter called MountPath' {
            $Function.Parameters.Keys.Contains('MountPath') | Should Be 'True'
            }
        It 'MountPath Parameter is Identified as Mandatory being False' {
            [String]$Function.Parameters.MountPath.Attributes.Mandatory | Should be 'False'
            }
        It 'MountPath Parameter is of String Type' {
            $Function.Parameters.MountPath.ParameterType.FullName | Should be 'System.String'
            }
        It 'MountPath Parameter is member of ParameterSets' {
            [String]$Function.Parameters.MountPath.ParameterSets.Keys | Should Be '__AllParameterSets'
            }
        It 'MountPath Parameter Position is defined correctly' {
            [String]$Function.Parameters.MountPath.Attributes.Position | Should be '2'
            }
        It 'Does MountPath Parameter Accept Pipeline Input?' {
            [String]$Function.Parameters.MountPath.Attributes.ValueFromPipeline | Should be 'False'
            }
        It 'Does MountPath Parameter Accept Pipeline Input by PropertyName?' {
            [String]$Function.Parameters.MountPath.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
            }
        It 'Does MountPath Parameter use advanced parameter Validation? ' {
            $Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
            $Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
            $Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
            $Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
            $Function.Parameters.MountPath.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
            }
        It 'Has Parameter Help Text for MountPath '{
            $function.Definition.Contains('.PARAMETER MountPath') | Should Be 'True'
            }
        It 'Has a Parameter called Artifact' {
            $Function.Parameters.Keys.Contains('Artifact') | Should Be 'True'
            }
        It 'Artifact Parameter is Identified as Mandatory being False' {
            [String]$Function.Parameters.Artifact.Attributes.Mandatory | Should be 'False'
            }
        It 'Artifact Parameter is of String[] Type' {
            $Function.Parameters.Artifact.ParameterType.FullName | Should be 'System.String[]'
            }
        It 'Artifact Parameter is member of ParameterSets' {
            [String]$Function.Parameters.Artifact.ParameterSets.Keys | Should Be '__AllParameterSets'
            }
        It 'Artifact Parameter Position is defined correctly' {
            [String]$Function.Parameters.Artifact.Attributes.Position | Should be '3'
            }
        It 'Does Artifact Parameter Accept Pipeline Input?' {
            [String]$Function.Parameters.Artifact.Attributes.ValueFromPipeline | Should be 'False'
            }
        It 'Does Artifact Parameter Accept Pipeline Input by PropertyName?' {
            [String]$Function.Parameters.Artifact.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
            }
        It 'Does Artifact Parameter use advanced parameter Validation? ' {
            $Function.Parameters.Artifact.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
            $Function.Parameters.Artifact.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
            $Function.Parameters.Artifact.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
            $Function.Parameters.Artifact.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
            $Function.Parameters.Artifact.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
            }
        It 'Has Parameter Help Text for Artifact '{
            $function.Definition.Contains('.PARAMETER Artifact') | Should Be 'True'
            }
        It 'Has a Parameter called ArtifactParam' {
            $Function.Parameters.Keys.Contains('ArtifactParam') | Should Be 'True'
            }
        It 'ArtifactParam Parameter is Identified as Mandatory being False' {
            [String]$Function.Parameters.ArtifactParam.Attributes.Mandatory | Should be 'False'
            }
        It 'ArtifactParam Parameter is of String[] Type' {
            $Function.Parameters.ArtifactParam.ParameterType.FullName | Should be 'System.String[]'
            }
        It 'ArtifactParam Parameter is member of ParameterSets' {
            [String]$Function.Parameters.ArtifactParam.ParameterSets.Keys | Should Be '__AllParameterSets'
            }
        It 'ArtifactParam Parameter Position is defined correctly' {
            [String]$Function.Parameters.ArtifactParam.Attributes.Position | Should be '4'
            }
        It 'Does ArtifactParam Parameter Accept Pipeline Input?' {
            [String]$Function.Parameters.ArtifactParam.Attributes.ValueFromPipeline | Should be 'False'
            }
        It 'Does ArtifactParam Parameter Accept Pipeline Input by PropertyName?' {
            [String]$Function.Parameters.ArtifactParam.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
            }
        It 'Does ArtifactParam Parameter use advanced parameter Validation? ' {
            $Function.Parameters.ArtifactParam.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
            $Function.Parameters.ArtifactParam.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
            $Function.Parameters.ArtifactParam.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
            $Function.Parameters.ArtifactParam.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
            $Function.Parameters.ArtifactParam.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
            }
        It 'Has Parameter Help Text for ArtifactParam '{
            $function.Definition.Contains('.PARAMETER ArtifactParam') | Should Be 'True'
            }
        It 'Has a Parameter called Force' {
            $Function.Parameters.Keys.Contains('Force') | Should Be 'True'
            }
        It 'Force Parameter is Identified as Mandatory being False' {
            [String]$Function.Parameters.Force.Attributes.Mandatory | Should be 'False'
            }
        It 'Force Parameter is of SwitchParameter Type' {
            $Function.Parameters.Force.ParameterType.FullName | Should be 'System.Management.Automation.SwitchParameter'
            }
        It 'Force Parameter is member of ParameterSets' {
            [String]$Function.Parameters.Force.ParameterSets.Keys | Should Be '__AllParameterSets'
            }
        It 'Force Parameter Position is defined correctly' {
            [String]$Function.Parameters.Force.Attributes.Position | Should be '-2147483648'
            }
        It 'Does Force Parameter Accept Pipeline Input?' {
            [String]$Function.Parameters.Force.Attributes.ValueFromPipeline | Should be 'False'
            }
        It 'Does Force Parameter Accept Pipeline Input by PropertyName?' {
            [String]$Function.Parameters.Force.Attributes.ValueFromPipelineByPropertyName | Should be 'False'
            }
        It 'Does Force Parameter use advanced parameter Validation? ' {
            $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullOrEmptyAttribute' | Should Be 'False'
            $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateNotNullAttribute' | Should Be 'False'
            $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateScript' | Should Be 'False'
            $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidateRangeAttribute' | Should Be 'False'
            $Function.Parameters.Force.Attributes.TypeID.Name -contains 'ValidatePatternAttribute' | Should Be 'False'
            }
        It 'Has Parameter Help Text for Force '{
            $function.Definition.Contains('.PARAMETER Force') | Should Be 'True'
            }
    }
    Context "Function $($function.Name) - Help Section" {

            It "Function $($function.Name) Has show-help comment block" {

                $function.Definition.Contains('<#') | should be 'True'
                $function.Definition.Contains('#>') | should be 'True'
            }

            It "Function $($function.Name) Has show-help comment block has a.SYNOPSIS" {

                $function.Definition.Contains('.SYNOPSIS') -or $function.Definition.Contains('.Synopsis') | should be 'True'

            }

            It "Function $($function.Name) Has show-help comment block has an example" {

                $function.Definition.Contains('.EXAMPLE') | should be 'True'
            }

            It "Function $($function.Name) Is an advanced function" {

                $function.CmdletBinding | should be 'True'
                $function.Definition.Contains('param') -or  $function.Definition.Contains('Param') | should be 'True'
            }
    
    }

 }