Add Parameter count test
This commit is contained in:
@@ -5,6 +5,10 @@ $global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 12 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
It "Has a mandatory string array parameter for the settings file to import" {
|
||||
Get-Command $global:function | Should -HaveParameter settingsFile
|
||||
Get-Command $global:function | Should -HaveParameter settingsFile -Mandatory
|
||||
|
||||
@@ -5,6 +5,10 @@ $global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 22 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 22
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'hostName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'datastoreName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
|
||||
@@ -5,6 +5,10 @@ $global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 20 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 20
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'checkpointIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@@ -39,7 +43,7 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
'ShouldProcess' {
|
||||
$scriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
$scriptBlock | Should -match 'SupportsShouldProcess'
|
||||
$scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
@@ -49,6 +53,10 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user