Functions/Private/Artifacts/AddRemovePrograms/Tests/Discover_AddRemovePrograms.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
Describe 'Discover_AddRemovePrograms Tests' {

   Context 'Parameters for Discover_AddRemovePrograms'{

        It 'Has a Parameter called MountPath' {
            $Function.Parameters.Keys.Contains('MountPath') | Should Be 'True'
            }
        It 'MountPath Parameter is Identified as Mandatory being True' {
            [String]$Function.Parameters.MountPath.Attributes.Mandatory | Should be 'True'
            }
        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 '0'
            }
        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 OutputPath' {
            $Function.Parameters.Keys.Contains('OutputPath') | Should Be 'True'
            }
        It 'OutputPath Parameter is Identified as Mandatory being True' {
            [String]$Function.Parameters.OutputPath.Attributes.Mandatory | Should be 'True'
            }
        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'
            }
    }
    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) Is an advanced function" {

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

 }