diff --git a/functions/Test-DbaJobOwner.ps1 b/functions/Test-DbaAgentJobOwner.ps1 similarity index 100% rename from functions/Test-DbaJobOwner.ps1 rename to functions/Test-DbaAgentJobOwner.ps1 diff --git a/internal/functions/Invoke-DbaDatabaseCorruption.ps1 b/internal/functions/Invoke-DbaDbCorruption.ps1 similarity index 91% rename from internal/functions/Invoke-DbaDatabaseCorruption.ps1 rename to internal/functions/Invoke-DbaDbCorruption.ps1 index 67cb3131ac..8733d7f472 100644 --- a/internal/functions/Invoke-DbaDatabaseCorruption.ps1 +++ b/internal/functions/Invoke-DbaDbCorruption.ps1 @@ -113,20 +113,20 @@ function Invoke-DbaDbCorruption { } if ("master", "tempdb", "model", "msdb" -contains $Database) { - Stop-Function -Message "You may not corrupt system databases." + Stop-Function -EnableException:$EnableException -Message "You may not corrupt system databases." return } try { $Server = Connect-SqlInstance -SqlInstance $SqlInstance -SqlCredential $SqlCredential -MinimumVersion 9 } catch { - Stop-Function -Message "Failure" -Category ConnectionError -ErrorRecord $_ -Target $SqlInstance + Stop-Function -EnableException:$EnableException -Message "Failure" -Category ConnectionError -ErrorRecord $_ -Target $SqlInstance return } $db = $Server.Databases | Where-Object { $_.Name -eq $Database } if (!$db) { - Stop-Function -Message "The database specified does not exist." + Stop-Function -EnableException:$EnableException -Message "The database specified does not exist." return } if ($Table) { @@ -136,13 +136,13 @@ function Invoke-DbaDbCorruption { } if (-not $tb) { - Stop-Function -Message "There are no accessible tables in $Database on $SqlInstance." -Target $Database + Stop-Function -EnableException:$EnableException -Message "There are no accessible tables in $Database on $SqlInstance." -Target $Database return } $RowCount = $db.Query("select top 1 * from $($tb.name)") if ($RowCount.count -eq 0) { - Stop-Function -Message "The table $tb has no rows" -Target $table + Stop-Function -EnableException:$EnableException -Message "The table $tb has no rows" -Target $table return } @@ -162,7 +162,7 @@ function Invoke-DbaDbCorruption { $Server.ConnectionContext.Disconnect() $Server.ConnectionContext.Connect() $null = Set-DbaDbState -SqlServer $Server -Database $Database -MultiUser -Force - Stop-Function -Message "Failed to write page" -Category WriteError -ErrorRecord $_ -Target $instance + Stop-Function -EnableException:$EnableException -Message "Failed to write page" -Category WriteError -ErrorRecord $_ -Target $instance return } diff --git a/internal/functions/Test-PSRemoting.ps1 b/internal/functions/Test-PSRemoting.ps1 index effc808e13..d9b232b3f4 100644 --- a/internal/functions/Test-PSRemoting.ps1 +++ b/internal/functions/Test-PSRemoting.ps1 @@ -22,7 +22,7 @@ function Test-PSRemoting { $true } catch { $false - Stop-Function -Message "Testing $($ComputerName.Computername)" -Target $ComputerName -ErrorRecord $_ + Stop-Function -Message "Testing $($ComputerName.Computername)" -Target $ComputerName -ErrorRecord $_ -EnableException:$EnableException } } #process diff --git a/tests/Add-DbaAgDatabase.Tests.ps1 b/tests/Add-DbaAgDatabase.Tests.ps1 index c85acbc784..8bb789a1ad 100644 --- a/tests/Add-DbaAgDatabase.Tests.ps1 +++ b/tests/Add-DbaAgDatabase.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Add-DbaAgDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Database', 'InputObject', 'EnableException', 'SeedingMode', 'SharedPath', 'UseLastBackup', 'Secondary', 'SecondarySqlCredential' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Database','Secondary','SecondarySqlCredential','InputObject','SeedingMode','SharedPath','UseLastBackup','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Add-DbaAgListener.Tests.ps1 b/tests/Add-DbaAgListener.Tests.ps1 index f84ff6a501..e8bc42d087 100644 --- a/tests/Add-DbaAgListener.Tests.ps1 +++ b/tests/Add-DbaAgListener.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Add-DbaAgListener).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'IPAddress', 'SubnetMask', 'Port', 'Dhcp', 'Passthru', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','IPAddress','SubnetMask','Port','Dhcp','Passthru','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Add-DbaAgReplica.Tests.ps1 b/tests/Add-DbaAgReplica.Tests.ps1 index 80fbb76626..fde8d6a2b8 100644 --- a/tests/Add-DbaAgReplica.Tests.ps1 +++ b/tests/Add-DbaAgReplica.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Add-DbaAgReplica).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'AvailabilityMode', 'FailoverMode', 'BackupPriority', 'ConnectionModeInPrimaryRole', 'ConnectionModeInSecondaryRole', 'SeedingMode', 'Endpoint', 'Passthru', 'ReadonlyRoutingConnectionUrl', 'Certificate', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','AvailabilityMode','FailoverMode','BackupPriority','ConnectionModeInPrimaryRole','ConnectionModeInSecondaryRole','SeedingMode','Endpoint','Passthru','ReadonlyRoutingConnectionUrl','Certificate','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Add-DbaCmsRegServer.Tests.ps1 b/tests/Add-DbaCmsRegServer.Tests.ps1 index 42fbff5fd5..3c8039969c 100644 --- a/tests/Add-DbaCmsRegServer.Tests.ps1 +++ b/tests/Add-DbaCmsRegServer.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'ServerName', 'Name', 'Description', 'Group', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','ServerName','Name','Description','Group','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Add-DbaCmsRegServerGroup.Tests.ps1 b/tests/Add-DbaCmsRegServerGroup.Tests.ps1 index 433fe3c916..64fa20ce0c 100644 --- a/tests/Add-DbaCmsRegServerGroup.Tests.ps1 +++ b/tests/Add-DbaCmsRegServerGroup.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'Description', 'Group', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','Description','Group','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Add-DbaComputerCertificate.Tests.ps1 b/tests/Add-DbaComputerCertificate.Tests.ps1 index 258e3d7366..6e31278adb 100644 --- a/tests/Add-DbaComputerCertificate.Tests.ps1 +++ b/tests/Add-DbaComputerCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Add-DbaComputerCertificate).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'SecurePassword', 'Certificate', 'Path', 'Store', 'Folder', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','SecurePassword','Certificate','Path','Store','Folder','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Add-DbaDbMirrorMonitor.Tests.ps1 b/tests/Add-DbaDbMirrorMonitor.Tests.ps1 index eabde7ca17..e07d8ca938 100644 --- a/tests/Add-DbaDbMirrorMonitor.Tests.ps1 +++ b/tests/Add-DbaDbMirrorMonitor.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 b/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 index 33078ac7da..1910722fbd 100644 --- a/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 +++ b/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Add-DbaPfDataCollectorCounter).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'Collector', 'Counter', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','Collector','Counter','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Backup-DbaDatabase.Tests.ps1 b/tests/Backup-DbaDatabase.Tests.ps1 index 753b9bef9a..a1d136a5cc 100644 --- a/tests/Backup-DbaDatabase.Tests.ps1 +++ b/tests/Backup-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 29 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Backup-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'BackupDirectory', 'BackupFileName', 'ReplaceInName', 'CopyOnly', 'Type', 'InputObject', 'CreateFolder', 'FileCount', 'CompressBackup', 'Checksum', 'Verify', 'MaxTransferSize', 'BlockSize', 'BufferCount', 'AzureBaseUrl', 'AzureCredential', 'NoRecovery', 'BuildPath', 'WithFormat', 'Initialize', 'SkipTapeHeader', 'TimeStampFormat', 'IgnoreFileChecks', 'OutputScriptOnly', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','BackupDirectory','BackupFileName','ReplaceInName','CopyOnly','Type','InputObject','CreateFolder','FileCount','CompressBackup','Checksum','Verify','MaxTransferSize','BlockSize','BufferCount','AzureBaseUrl','AzureCredential','NoRecovery','BuildPath','WithFormat','Initialize','SkipTapeHeader','TimeStampFormat','IgnoreFileChecks','OutputScriptOnly','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Backup-DbaDbCertificate.Tests.ps1 b/tests/Backup-DbaDbCertificate.Tests.ps1 index 6d141e69c1..cd15a4f6c9 100644 --- a/tests/Backup-DbaDbCertificate.Tests.ps1 +++ b/tests/Backup-DbaDbCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 11 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Backup-DbaDbCertificate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Certificate', 'Database', 'ExcludeDatabase', 'EncryptionPassword', 'DecryptionPassword', 'Path', 'Suffix', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Certificate','Database','ExcludeDatabase','EncryptionPassword','DecryptionPassword','Path','Suffix','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Backup-DbaDbMasterKey.Tests.ps1 b/tests/Backup-DbaDbMasterKey.Tests.ps1 index 3c18c8c09f..277b4d2a17 100644 --- a/tests/Backup-DbaDbMasterKey.Tests.ps1 +++ b/tests/Backup-DbaDbMasterKey.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Backup-DbaDbMasterKey).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'Database', 'ExcludeDatabase', 'SecurePassword', 'Path', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','Database','ExcludeDatabase','SecurePassword','Path','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Clear-DbaConnectionPool.Tests.ps1 b/tests/Clear-DbaConnectionPool.Tests.ps1 index 66f60c7413..a917c20f77 100644 --- a/tests/Clear-DbaConnectionPool.Tests.ps1 +++ b/tests/Clear-DbaConnectionPool.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Clear-DbaConnectionPool).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Clear-DbaLatchStatistics.Tests.ps1 b/tests/Clear-DbaLatchStatistics.Tests.ps1 index 4e4d529fcb..5babaa8748 100644 --- a/tests/Clear-DbaLatchStatistics.Tests.ps1 +++ b/tests/Clear-DbaLatchStatistics.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - $paramCount = $knownParameters.Count - $SupportShouldProcess = $true - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Clear-DbaPlanCache.Tests.ps1 b/tests/Clear-DbaPlanCache.Tests.ps1 index 16509deb97..1cd3a6fa2a 100644 --- a/tests/Clear-DbaPlanCache.Tests.ps1 +++ b/tests/Clear-DbaPlanCache.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Clear-DbaPlanCache).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Threshold', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Threshold','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Clear-DbaWaitStatistics.Tests.ps1 b/tests/Clear-DbaWaitStatistics.Tests.ps1 index 6c8e6e1370..dad08e1183 100644 --- a/tests/Clear-DbaWaitStatistics.Tests.ps1 +++ b/tests/Clear-DbaWaitStatistics.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Clear-DbaWaitStatistics).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Connect-DbaInstance.Tests.ps1 b/tests/Connect-DbaInstance.Tests.ps1 index e304a376ea..ba17a656cb 100644 --- a/tests/Connect-DbaInstance.Tests.ps1 +++ b/tests/Connect-DbaInstance.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Connect-DbaInstance).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'AccessToken', 'ApplicationIntent', 'BatchSeparator', 'ClientName', 'ConnectTimeout', 'EncryptConnection', 'FailoverPartner', 'LockTimeout', 'MaxPoolSize', 'MinPoolSize', 'MultipleActiveResultSets', 'MultiSubnetFailover', 'NetworkProtocol', 'NonPooledConnection', 'PacketSize', 'PooledConnectionLifetime', 'SqlExecutionModes', 'StatementTimeout', 'TrustServerCertificate', 'WorkstationId', 'AppendConnectionString', 'SqlConnectionOnly', 'DisableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','AccessToken','ApplicationIntent','BatchSeparator','ClientName','ConnectTimeout','EncryptConnection','FailoverPartner','LockTimeout','MaxPoolSize','MinPoolSize','MultipleActiveResultSets','MultiSubnetFailover','NetworkProtocol','NonPooledConnection','PacketSize','PooledConnectionLifetime','SqlExecutionModes','StatementTimeout','TrustServerCertificate','WorkstationId','AppendConnectionString','SqlConnectionOnly','DisableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Connect-SqlInstance.Tests.ps1 b/tests/Connect-SqlInstance.Tests.ps1 index 1207e0bd6a..457dee2576 100644 --- a/tests/Connect-SqlInstance.Tests.ps1 +++ b/tests/Connect-SqlInstance.Tests.ps1 @@ -3,6 +3,18 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" . "$PSScriptRoot\..\internal\functions\Connect-SqlInstance.ps1" +Describe "$commandname Unit Tests" -Tags "UnitTests" { + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','ParameterConnection','RegularUser','StatementTimeout','MinimumVersion','AzureUnsupported','NonPooled' + + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} + Describe "$commandname Integration Tests" -Tags "IntegrationTests" { $password = 'MyV3ry$ecur3P@ssw0rd' $securePassword = ConvertTo-SecureString $password -AsPlainText -Force diff --git a/tests/ConvertTo-DbaDataTable.Tests.ps1 b/tests/ConvertTo-DbaDataTable.Tests.ps1 index 233d0a453b..f8f1f4b79f 100644 --- a/tests/ConvertTo-DbaDataTable.Tests.ps1 +++ b/tests/ConvertTo-DbaDataTable.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\ConvertTo-DbaDataTable).Parameters.Keys - $knownParameters = 'InputObject', 'TimeSpanType', 'SizeType', 'IgnoreNull', 'Raw', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','TimeSpanType','SizeType','IgnoreNull','Raw','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/ConvertTo-DbaTimeline.Tests.ps1 b/tests/ConvertTo-DbaTimeline.Tests.ps1 index fa151c0d6b..afd171ab05 100644 --- a/tests/ConvertTo-DbaTimeline.Tests.ps1 +++ b/tests/ConvertTo-DbaTimeline.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\ConvertTo-DbaTimeline).Parameters.Keys - $knownParameters = 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/ConvertTo-DbaXESession.Tests.ps1 b/tests/ConvertTo-DbaXESession.Tests.ps1 index 00044e0b67..816344a2ce 100644 --- a/tests/ConvertTo-DbaXESession.Tests.ps1 +++ b/tests/ConvertTo-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\ConvertTo-DbaXESession).Parameters.Keys - $knownParameters = 'InputObject', 'Name', 'OutputScriptOnly', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','Name','OutputScriptOnly','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaAgentAlert.Tests.ps1 b/tests/Copy-DbaAgentAlert.Tests.ps1 index 06c1b4272a..2f89a3dc58 100644 --- a/tests/Copy-DbaAgentAlert.Tests.ps1 +++ b/tests/Copy-DbaAgentAlert.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaAgentAlert).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Alert', 'ExcludeAlert', 'IncludeDefaults', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Alert','ExcludeAlert','IncludeDefaults','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaAgentJob.Tests.ps1 b/tests/Copy-DbaAgentJob.Tests.ps1 index c08e24cf86..548bfffbb3 100644 --- a/tests/Copy-DbaAgentJob.Tests.ps1 +++ b/tests/Copy-DbaAgentJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaAgentJob).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Job', 'ExcludeJob', 'DisableOnSource', 'DisableOnDestination', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Job','ExcludeJob','DisableOnSource','DisableOnDestination','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaAgentJobCategory.Tests.ps1 b/tests/Copy-DbaAgentJobCategory.Tests.ps1 index 31fbc77ca9..d74d5ec5f8 100644 --- a/tests/Copy-DbaAgentJobCategory.Tests.ps1 +++ b/tests/Copy-DbaAgentJobCategory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaAgentJobCategory).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'CategoryType', 'JobCategory', 'AgentCategory', 'OperatorCategory', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','CategoryType','JobCategory','AgentCategory','OperatorCategory','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaAgentOperator.Tests.ps1 b/tests/Copy-DbaAgentOperator.Tests.ps1 index d73c224162..e310c4c011 100644 --- a/tests/Copy-DbaAgentOperator.Tests.ps1 +++ b/tests/Copy-DbaAgentOperator.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaAgentOperator).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Operator', 'ExcludeOperator', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Operator','ExcludeOperator','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaAgentProxy.Tests.ps1 b/tests/Copy-DbaAgentProxy.Tests.ps1 index c561af0c77..41c9eb4d1c 100644 --- a/tests/Copy-DbaAgentProxy.Tests.ps1 +++ b/tests/Copy-DbaAgentProxy.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaAgentProxy).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'ProxyAccount', 'ExcludeProxyAccount', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','ProxyAccount','ExcludeProxyAccount','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaAgentSchedule.Tests.ps1 b/tests/Copy-DbaAgentSchedule.Tests.ps1 index 7252aab89d..f5d079ac56 100644 --- a/tests/Copy-DbaAgentSchedule.Tests.ps1 +++ b/tests/Copy-DbaAgentSchedule.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaAgentSchedule).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaAgentServer.Tests.ps1 b/tests/Copy-DbaAgentServer.Tests.ps1 index 3daa896aaa..83fb422a70 100644 --- a/tests/Copy-DbaAgentServer.Tests.ps1 +++ b/tests/Copy-DbaAgentServer.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaAgentServer).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'DisableJobsOnDestination', 'DisableJobsOnSource', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','DisableJobsOnDestination','DisableJobsOnSource','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaBackupDevice.Tests.ps1 b/tests/Copy-DbaBackupDevice.Tests.ps1 index ea09408a6a..25b39c4e95 100644 --- a/tests/Copy-DbaBackupDevice.Tests.ps1 +++ b/tests/Copy-DbaBackupDevice.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaBackupDevice).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'BackupDevice', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','BackupDevice','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaCmsRegServer.Tests.ps1 b/tests/Copy-DbaCmsRegServer.Tests.ps1 index d27453c900..3f3997c457 100644 --- a/tests/Copy-DbaCmsRegServer.Tests.ps1 +++ b/tests/Copy-DbaCmsRegServer.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaCmsRegServer).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Group', 'SwitchServerName', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Group','SwitchServerName','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaCredential.Tests.ps1 b/tests/Copy-DbaCredential.Tests.ps1 index edca1f29d2..70c8f84b17 100644 --- a/tests/Copy-DbaCredential.Tests.ps1 +++ b/tests/Copy-DbaCredential.Tests.ps1 @@ -5,15 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 11 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaCredential).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Credential', 'Destination', 'DestinationSqlCredential', 'Name', 'ExcludeName', 'Identity', 'ExcludeIdentity', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Credential','Destination','DestinationSqlCredential','Name','ExcludeName','Identity','ExcludeIdentity','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaCustomError.Tests.ps1 b/tests/Copy-DbaCustomError.Tests.ps1 index 6dfd5517fc..7a98338976 100644 --- a/tests/Copy-DbaCustomError.Tests.ps1 +++ b/tests/Copy-DbaCustomError.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaCustomError).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'CustomError', 'ExcludeCustomError', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','CustomError','ExcludeCustomError','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaDataCollector.Tests.ps1 b/tests/Copy-DbaDataCollector.Tests.ps1 index 41db513cc8..50fb20b731 100644 --- a/tests/Copy-DbaDataCollector.Tests.ps1 +++ b/tests/Copy-DbaDataCollector.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaDataCollector).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'CollectionSet', 'ExcludeCollectionSet', 'NoServerReconfig', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','CollectionSet','ExcludeCollectionSet','NoServerReconfig','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaDatabase.Tests.ps1 b/tests/Copy-DbaDatabase.Tests.ps1 index ac4aef1311..acca84d416 100644 --- a/tests/Copy-DbaDatabase.Tests.ps1 +++ b/tests/Copy-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 27 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaDatabase).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Database', 'ExcludeDatabase', 'AllDatabases', 'BackupRestore', 'SharedPath', 'WithReplace', 'NoRecovery', 'NoBackupCleanup', 'NumberFiles', 'DetachAttach', 'Reattach', 'SetSourceReadOnly', 'ReuseSourceFolderStructure', 'IncludeSupportDbs', 'UseLastBackup', 'Continue', 'InputObject', 'NoCopyOnly', 'SetSourceOffline', 'NewName', 'Prefix', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Database','ExcludeDatabase','AllDatabases','BackupRestore','SharedPath','WithReplace','NoRecovery','NoBackupCleanup','NumberFiles','DetachAttach','Reattach','SetSourceReadOnly','ReuseSourceFolderStructure','IncludeSupportDbs','UseLastBackup','Continue','InputObject','NoCopyOnly','SetSourceOffline','NewName','Prefix','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaDbAssembly.Tests.ps1 b/tests/Copy-DbaDbAssembly.Tests.ps1 index 64a03f2931..d8723e09bb 100644 --- a/tests/Copy-DbaDbAssembly.Tests.ps1 +++ b/tests/Copy-DbaDbAssembly.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaDbAssembly).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Assembly', 'ExcludeAssembly', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Assembly','ExcludeAssembly','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaDbMail.Tests.ps1 b/tests/Copy-DbaDbMail.Tests.ps1 index 5223b6face..01b29b9ce7 100644 --- a/tests/Copy-DbaDbMail.Tests.ps1 +++ b/tests/Copy-DbaDbMail.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaDbMail).Parameters.Keys - $knownParameters = 'Source', 'Destination', 'Type', 'SourceSqlCredential', 'DestinationSqlCredential', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','Destination','Type','SourceSqlCredential','DestinationSqlCredential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 b/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 index c9dfcd32ad..a76f9dfd1c 100644 --- a/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 +++ b/tests/Copy-DbaDbQueryStoreOption.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaDbQueryStoreOption).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'SourceDatabase', 'Destination', 'DestinationSqlCredential', 'DestinationDatabase', 'Exclude', 'AllDatabases', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','SourceDatabase','Destination','DestinationSqlCredential','DestinationDatabase','Exclude','AllDatabases','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaDbTableData.Tests.ps1 b/tests/Copy-DbaDbTableData.Tests.ps1 index 41cf1eeab9..a922905010 100644 --- a/tests/Copy-DbaDbTableData.Tests.ps1 +++ b/tests/Copy-DbaDbTableData.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 21 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaDbTableData).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Destination', 'DestinationSqlCredential', 'Database', 'DestinationDatabase', 'Table', 'Query', 'BatchSize', 'NotifyAfter', 'DestinationTable', 'NoTableLock', 'CheckConstraints', 'FireTriggers', 'KeepIdentity', 'KeepNulls', 'Truncate', 'bulkCopyTimeOut', 'InputObject', 'EnableException', 'AutoCreateTable' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Destination','DestinationSqlCredential','Database','DestinationDatabase','Table','Query','AutoCreateTable','BatchSize','NotifyAfter','DestinationTable','NoTableLock','CheckConstraints','FireTriggers','KeepIdentity','KeepNulls','Truncate','bulkCopyTimeOut','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaEndpoint.Tests.ps1 b/tests/Copy-DbaEndpoint.Tests.ps1 index 1b3dbe5b0e..ee22a43ab1 100644 --- a/tests/Copy-DbaEndpoint.Tests.ps1 +++ b/tests/Copy-DbaEndpoint.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaEndpoint).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Endpoint', 'ExcludeEndpoint', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Endpoint','ExcludeEndpoint','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaLinkedServer.Tests.ps1 b/tests/Copy-DbaLinkedServer.Tests.ps1 index 2bb2c04dd7..8871f12e5d 100644 --- a/tests/Copy-DbaLinkedServer.Tests.ps1 +++ b/tests/Copy-DbaLinkedServer.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaLinkedServer).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'LinkedServer', 'ExcludeLinkedServer', 'UpgradeSqlClient', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','LinkedServer','ExcludeLinkedServer','UpgradeSqlClient','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaLogin.Tests.ps1 b/tests/Copy-DbaLogin.Tests.ps1 index 470c0b19bf..05fae7c466 100644 --- a/tests/Copy-DbaLogin.Tests.ps1 +++ b/tests/Copy-DbaLogin.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 16 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaLogin).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Login', 'ExcludeLogin', 'ExcludeSystemLogins', 'SyncOnly', 'SyncSaName', 'OutFile', 'InputObject', 'LoginRenameHashtable', 'KillActiveConnection', 'Force', 'EnableException', 'ExcludePermissionSync' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Login','ExcludeLogin','ExcludeSystemLogins','SyncOnly','SyncSaName','OutFile','InputObject','LoginRenameHashtable','KillActiveConnection','Force','ExcludePermissionSync','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaPolicyManagement.Tests.ps1 b/tests/Copy-DbaPolicyManagement.Tests.ps1 index b55c956666..51c99fc689 100644 --- a/tests/Copy-DbaPolicyManagement.Tests.ps1 +++ b/tests/Copy-DbaPolicyManagement.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaPolicyManagement).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Policy', 'ExcludePolicy', 'Condition', 'ExcludeCondition', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Policy','ExcludePolicy','Condition','ExcludeCondition','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaResourceGovernor.Tests.ps1 b/tests/Copy-DbaResourceGovernor.Tests.ps1 index 0a807807ec..e705382932 100644 --- a/tests/Copy-DbaResourceGovernor.Tests.ps1 +++ b/tests/Copy-DbaResourceGovernor.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaResourceGovernor).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'ResourcePool', 'ExcludeResourcePool', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','ResourcePool','ExcludeResourcePool','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaServerAudit.Tests.ps1 b/tests/Copy-DbaServerAudit.Tests.ps1 index 6638f6df07..2b125fd4ac 100644 --- a/tests/Copy-DbaServerAudit.Tests.ps1 +++ b/tests/Copy-DbaServerAudit.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Copy-DbaServerAudit).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Audit', 'ExcludeAudit', 'Path', 'Force', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Audit','ExcludeAudit','Path','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaServerAuditSpecification.Tests.ps1 b/tests/Copy-DbaServerAuditSpecification.Tests.ps1 index 16508d38bb..afbbe3722e 100644 --- a/tests/Copy-DbaServerAuditSpecification.Tests.ps1 +++ b/tests/Copy-DbaServerAuditSpecification.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaServerAuditSpecification).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'AuditSpecification', 'ExcludeAuditSpecification', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','AuditSpecification','ExcludeAuditSpecification','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaServerTrigger.Tests.ps1 b/tests/Copy-DbaServerTrigger.Tests.ps1 index a0b828051e..ebd8437534 100644 --- a/tests/Copy-DbaServerTrigger.Tests.ps1 +++ b/tests/Copy-DbaServerTrigger.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaServerTrigger).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'ServerTrigger', 'ExcludeServerTrigger', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','ServerTrigger','ExcludeServerTrigger','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaSpConfigure.Tests.ps1 b/tests/Copy-DbaSpConfigure.Tests.ps1 index bbe5b6893d..f4fa815e34 100644 --- a/tests/Copy-DbaSpConfigure.Tests.ps1 +++ b/tests/Copy-DbaSpConfigure.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaSpConfigure).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'ConfigName', 'ExcludeConfigName', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','ConfigName','ExcludeConfigName','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaSsisCatalog.Tests.ps1 b/tests/Copy-DbaSsisCatalog.Tests.ps1 index 7536ed04fe..bcbe360bed 100644 --- a/tests/Copy-DbaSsisCatalog.Tests.ps1 +++ b/tests/Copy-DbaSsisCatalog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 11 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaSsisCatalog).Parameters.Keys - $knownParameters = 'Source', 'Destination', 'SourceSqlCredential', 'DestinationSqlCredential', 'Project', 'Folder', 'Environment', 'CreateCatalogPassword', 'EnableSqlClr', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','Destination','SourceSqlCredential','DestinationSqlCredential','Project','Folder','Environment','CreateCatalogPassword','EnableSqlClr','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaSysDbUserObject.Tests.ps1 b/tests/Copy-DbaSysDbUserObject.Tests.ps1 index 2236d44e11..a973e1446f 100644 --- a/tests/Copy-DbaSysDbUserObject.Tests.ps1 +++ b/tests/Copy-DbaSysDbUserObject.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaSysDbUserObject).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Force', 'Classic', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Force','Classic','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaXESession.Tests.ps1 b/tests/Copy-DbaXESession.Tests.ps1 index 7cb0999f2b..06e8b5c9c6 100644 --- a/tests/Copy-DbaXESession.Tests.ps1 +++ b/tests/Copy-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Copy-DbaXESession).Parameters.Keys - $knownParameters = 'Source', 'Destination', 'SourceSqlCredential', 'DestinationSqlCredential', 'XeSession', 'ExcludeXeSession', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','Destination','SourceSqlCredential','DestinationSqlCredential','XeSession','ExcludeXeSession','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Copy-DbaXESessionTemplate.Tests.ps1 b/tests/Copy-DbaXESessionTemplate.Tests.ps1 index 5fbf6e1b49..84d12b9a45 100644 --- a/tests/Copy-DbaXESessionTemplate.Tests.ps1 +++ b/tests/Copy-DbaXESessionTemplate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Copy-DbaXESessionTemplate).Parameters.Keys - $knownParameters = 'Path', 'Destination', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','Destination','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Disable-DbaAgHadr.Tests.ps1 b/tests/Disable-DbaAgHadr.Tests.ps1 index d36044ecd3..adb2d8dd90 100644 --- a/tests/Disable-DbaAgHadr.Tests.ps1 +++ b/tests/Disable-DbaAgHadr.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - $paramCount = 4 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Disable-DbaAgHadr).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'Force', 'EnableException' - It "Should contian our specifc parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Disable-DbaFilestream.Tests.ps1 b/tests/Disable-DbaFilestream.Tests.ps1 index 31f2e133f8..b5749bb45c 100644 --- a/tests/Disable-DbaFilestream.Tests.ps1 +++ b/tests/Disable-DbaFilestream.Tests.ps1 @@ -5,22 +5,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Disable-DbaFilestream).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Disable-DbaForceNetworkEncryption.Tests.ps1 b/tests/Disable-DbaForceNetworkEncryption.Tests.ps1 index 47f223586e..913ad53c7a 100644 --- a/tests/Disable-DbaForceNetworkEncryption.Tests.ps1 +++ b/tests/Disable-DbaForceNetworkEncryption.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Disable-DbaForceNetworkEncryption).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Disable-DbaTraceFlag.Tests.ps1 b/tests/Disable-DbaTraceFlag.Tests.ps1 index 02fc7d8cdc..a75b318dc8 100644 --- a/tests/Disable-DbaTraceFlag.Tests.ps1 +++ b/tests/Disable-DbaTraceFlag.Tests.ps1 @@ -4,12 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'TraceFlag', 'EnableException' - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'TraceFlag', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','TraceFlag','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Dismount-DbaDatabase.Tests.ps1 b/tests/Dismount-DbaDatabase.Tests.ps1 index 869de71469..fc941ffd56 100644 --- a/tests/Dismount-DbaDatabase.Tests.ps1 +++ b/tests/Dismount-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Dismount-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'UpdateStatistics', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','UpdateStatistics','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Enable-DbaAgHadr.Tests.ps1 b/tests/Enable-DbaAgHadr.Tests.ps1 index 1a406bfa10..d8cddb8eac 100644 --- a/tests/Enable-DbaAgHadr.Tests.ps1 +++ b/tests/Enable-DbaAgHadr.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - $paramCount = 4 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Enable-DbaAgHadr).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'Force', 'EnableException' - it "Should contian our specifc parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Enable-DbaFilestream.Tests.ps1 b/tests/Enable-DbaFilestream.Tests.ps1 index d5a516503c..f9833da117 100644 --- a/tests/Enable-DbaFilestream.Tests.ps1 +++ b/tests/Enable-DbaFilestream.Tests.ps1 @@ -5,22 +5,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Enable-DbaFilestream).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'FileStreamLevel', 'ShareName', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','FileStreamLevel','ShareName','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Enable-DbaForceNetworkEncryption.Tests.ps1 b/tests/Enable-DbaForceNetworkEncryption.Tests.ps1 index 5f7dbd33f4..80dbdb5a16 100644 --- a/tests/Enable-DbaForceNetworkEncryption.Tests.ps1 +++ b/tests/Enable-DbaForceNetworkEncryption.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Enable-DbaForceNetworkEncryption).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Enable-DbaTraceFlag.Tests.ps1 b/tests/Enable-DbaTraceFlag.Tests.ps1 index bdd58bb0f6..57466aa8fe 100644 --- a/tests/Enable-DbaTraceFlag.Tests.ps1 +++ b/tests/Enable-DbaTraceFlag.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'TraceFlag', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','TraceFlag','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Expand-DbaDbLogFile.Tests.ps1 b/tests/Expand-DbaDbLogFile.Tests.ps1 index a62a8a5f0e..1ee4f895e1 100644 --- a/tests/Expand-DbaDbLogFile.Tests.ps1 +++ b/tests/Expand-DbaDbLogFile.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 12 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Expand-DbaDbLogFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'TargetLogSize', 'IncrementSize', 'LogFileId', 'ShrinkLogFile', 'ShrinkSize', 'BackupDirectory', 'ExcludeDiskSpaceValidation', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','TargetLogSize','IncrementSize','LogFileId','ShrinkLogFile','ShrinkSize','BackupDirectory','ExcludeDiskSpaceValidation','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaAvailabilityGroup.Tests.ps1 b/tests/Export-DbaAvailabilityGroup.Tests.ps1 index e14f805cf6..a2ba81347b 100644 --- a/tests/Export-DbaAvailabilityGroup.Tests.ps1 +++ b/tests/Export-DbaAvailabilityGroup.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Export-DbaAvailabilityGroup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'ExcludeAvailabilityGroup', 'Path', 'NoClobber', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','ExcludeAvailabilityGroup','Path','NoClobber','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaCmsRegServer.Tests.ps1 b/tests/Export-DbaCmsRegServer.Tests.ps1 index fc34bc0f90..fbec9cb643 100644 --- a/tests/Export-DbaCmsRegServer.Tests.ps1 +++ b/tests/Export-DbaCmsRegServer.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'InputObject', 'Path', 'CredentialPersistenceType', 'EnableException' - $SupportShouldProcess = $false - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','InputObject','Path','CredentialPersistenceType','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaCredential.Tests.ps1 b/tests/Export-DbaCredential.Tests.ps1 index 09d1d7452d..164df5fc86 100644 --- a/tests/Export-DbaCredential.Tests.ps1 +++ b/tests/Export-DbaCredential.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaCredential).Parameters.Keys - $knownParameters = 'SqlInstance', 'Identity', 'SqlCredential', 'Credential', 'Path', 'ExcludePassword', 'Append', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Identity','SqlCredential','Credential','Path','ExcludePassword','Append','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaDacPackage.Tests.ps1 b/tests/Export-DbaDacPackage.Tests.ps1 index f700dc2c97..b1cccd6eff 100644 --- a/tests/Export-DbaDacPackage.Tests.ps1 +++ b/tests/Export-DbaDacPackage.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 12 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaDacPackage).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'AllUserDatabases', 'Path', 'ExtendedParameters', 'ExtendedProperties', 'EnableException', 'Type', 'DacOption', 'Table' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','AllUserDatabases','Path','DacOption','ExtendedParameters','ExtendedProperties','Type','Table','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaDiagnosticQuery.Tests.ps1 b/tests/Export-DbaDiagnosticQuery.Tests.ps1 index e1894c725e..87d9e7a494 100644 --- a/tests/Export-DbaDiagnosticQuery.Tests.ps1 +++ b/tests/Export-DbaDiagnosticQuery.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaDiagnosticQuery).Parameters.Keys - $knownParameters = 'InputObject', 'ConvertTo', 'Path', 'Suffix', 'NoPlanExport', 'NoQueryExport', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','ConvertTo','Path','Suffix','NoPlanExport','NoQueryExport','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaExecutionPlan.Tests.ps1 b/tests/Export-DbaExecutionPlan.Tests.ps1 index 41e44a14f7..cf08b2dd87 100644 --- a/tests/Export-DbaExecutionPlan.Tests.ps1 +++ b/tests/Export-DbaExecutionPlan.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Export-DbaExecutionPlan).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Path', 'SinceCreation', 'SinceLastExecution', 'PipedObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Path','SinceCreation','SinceLastExecution','PipedObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaInstance.Tests.ps1 b/tests/Export-DbaInstance.Tests.ps1 index a50cfcfe14..d8d470c7ae 100644 --- a/tests/Export-DbaInstance.Tests.ps1 +++ b/tests/Export-DbaInstance.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaInstance).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'Path', 'NoRecovery', 'IncludeDbMasterKey', 'Exclude', 'BatchSeparator', 'ScriptingOption', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','Path','NoRecovery','IncludeDbMasterKey','Exclude','BatchSeparator','ScriptingOption','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaLinkedServer.Tests.ps1 b/tests/Export-DbaLinkedServer.Tests.ps1 index 51ceb9d7df..48f93fabc7 100644 --- a/tests/Export-DbaLinkedServer.Tests.ps1 +++ b/tests/Export-DbaLinkedServer.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaLinkedServer).Parameters.Keys - $knownParameters = 'SqlInstance', 'LinkedServer', 'SqlCredential', 'Credential', 'Path', 'ExcludePassword', 'Append', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','LinkedServer','SqlCredential','Credential','Path','ExcludePassword','Append','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaLogin.Tests.ps1 b/tests/Export-DbaLogin.Tests.ps1 index 3fb3f65712..38b1957141 100644 --- a/tests/Export-DbaLogin.Tests.ps1 +++ b/tests/Export-DbaLogin.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 13 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Export-DbaLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'ExcludeLogin', 'Database', 'Path', 'NoClobber', 'Append', 'ExcludeDatabases', 'ExcludeJobs', 'EnableException', 'ExcludeGoBatchSeparator', 'DestinationVersion' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','ExcludeLogin','Database','Path','NoClobber','Append','ExcludeDatabases','ExcludeJobs','EnableException','ExcludeGoBatchSeparator','DestinationVersion' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 b/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 index 944768492f..b1ead8dc40 100644 --- a/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 +++ b/tests/Export-DbaPfDataCollectorSetTemplate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaPfDataCollectorSetTemplate).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'Path', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','Path','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaRepServerSetting.Tests.ps1 b/tests/Export-DbaRepServerSetting.Tests.ps1 index 13dca33d07..0e8e37f5a7 100644 --- a/tests/Export-DbaRepServerSetting.Tests.ps1 +++ b/tests/Export-DbaRepServerSetting.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaRepServerSetting).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'ScriptOption', 'InputObject', 'Encoding', 'Passthru', 'NoClobber', 'Append', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','ScriptOption','InputObject','Encoding','Passthru','NoClobber','Append','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaScript.Tests.ps1 b/tests/Export-DbaScript.Tests.ps1 index 8de587df6b..441ac8183c 100644 --- a/tests/Export-DbaScript.Tests.ps1 +++ b/tests/Export-DbaScript.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Export-DbaScript).Parameters.Keys - $knownParameters = 'InputObject', 'ScriptingOptionsObject', 'Path', 'Encoding', 'BatchSeparator', 'NoPrefix', 'Passthru', 'NoClobber', 'Append', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','ScriptingOptionsObject','Path','Encoding','BatchSeparator','NoPrefix','Passthru','NoClobber','Append','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaSpConfigure.Tests.ps1 b/tests/Export-DbaSpConfigure.Tests.ps1 index 44df8019fd..36cedf85a8 100644 --- a/tests/Export-DbaSpConfigure.Tests.ps1 +++ b/tests/Export-DbaSpConfigure.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaSpConfigure).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaUser.Tests.ps1 b/tests/Export-DbaUser.Tests.ps1 index 839fb7912b..02ae311e52 100644 --- a/tests/Export-DbaUser.Tests.ps1 +++ b/tests/Export-DbaUser.Tests.ps1 @@ -5,15 +5,11 @@ $outputFile = "$env:temp\dbatoolsci_user.sql" Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 12 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaUser).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'User', 'DestinationVersion', 'Path', 'NoClobber', 'Append', 'EnableException', 'ScriptingOptionsObject', 'ExcludeGoBatchSeparator' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','User','DestinationVersion','Path','NoClobber','Append','EnableException','ScriptingOptionsObject','ExcludeGoBatchSeparator' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaXECsv.Tests.ps1 b/tests/Export-DbaXECsv.Tests.ps1 index c3a258c224..f234a75605 100644 --- a/tests/Export-DbaXECsv.Tests.ps1 +++ b/tests/Export-DbaXECsv.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaXECsv).Parameters.Keys - $knownParameters = 'InputObject', 'Path', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','Path','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Export-DbaXESessionTemplate.Tests.ps1 b/tests/Export-DbaXESessionTemplate.Tests.ps1 index 9100cfc6e4..7b78e6364d 100644 --- a/tests/Export-DbaXESessionTemplate.Tests.ps1 +++ b/tests/Export-DbaXESessionTemplate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Export-DbaXESessionTemplate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Session', 'Path', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Session','Path','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaAgentJob.Tests.ps1 b/tests/Find-DbaAgentJob.Tests.ps1 index c251948288..4eb5d8927a 100644 --- a/tests/Find-DbaAgentJob.Tests.ps1 +++ b/tests/Find-DbaAgentJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 14 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaAgentJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'JobName', 'ExcludeJobName', 'StepName', 'LastUsed', 'IsDisabled', 'IsFailed', 'IsNotScheduled', 'IsNoEmailNotification', 'Category', 'Owner', 'Since', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','JobName','ExcludeJobName','StepName','LastUsed','IsDisabled','IsFailed','IsNotScheduled','IsNoEmailNotification','Category','Owner','Since','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaBackup.Tests.ps1 b/tests/Find-DbaBackup.Tests.ps1 index ba2e3b9008..f4d5d3f814 100644 --- a/tests/Find-DbaBackup.Tests.ps1 +++ b/tests/Find-DbaBackup.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaBackup).Parameters.Keys - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','BackupFileExtension','RetentionPeriod','CheckArchiveBit','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaCommand.Tests.ps1 b/tests/Find-DbaCommand.Tests.ps1 index 750f57da67..f032ef6026 100644 --- a/tests/Find-DbaCommand.Tests.ps1 +++ b/tests/Find-DbaCommand.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Find-DbaCommand).Parameters.Keys - $knownParameters = 'Pattern', 'Tag', 'Author', 'MinimumVersion', 'MaximumVersion', 'Rebuild', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Pattern','Tag','Author','MinimumVersion','MaximumVersion','Rebuild','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaDatabase.Tests.ps1 b/tests/Find-DbaDatabase.Tests.ps1 index 48f7e1b70a..6f489ddb31 100644 --- a/tests/Find-DbaDatabase.Tests.ps1 +++ b/tests/Find-DbaDatabase.Tests.ps1 @@ -10,22 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\$CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Property', 'Pattern', 'Exact', 'EnableException', 'Detailed' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Property','Pattern','Exact','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaDbGrowthEvent.Tests.ps1 b/tests/Find-DbaDbGrowthEvent.Tests.ps1 index 2440852534..89b9c57093 100644 --- a/tests/Find-DbaDbGrowthEvent.Tests.ps1 +++ b/tests/Find-DbaDbGrowthEvent.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaDbGrowthEvent).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EventType', 'FileType', 'UseLocalTime', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EventType','FileType','UseLocalTime','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaDbUnusedIndex.Tests.ps1 b/tests/Find-DbaDbUnusedIndex.Tests.ps1 index 2c8ed6f605..433a31e229 100644 --- a/tests/Find-DbaDbUnusedIndex.Tests.ps1 +++ b/tests/Find-DbaDbUnusedIndex.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaDbUnusedIndex).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IgnoreUptime', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IgnoreUptime','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaDisabledIndex.Tests.ps1 b/tests/Find-DbaDisabledIndex.Tests.ps1 index d1443dae2a..e4fda7c7fa 100644 --- a/tests/Find-DbaDisabledIndex.Tests.ps1 +++ b/tests/Find-DbaDisabledIndex.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Find-DbaDisabledIndex).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'NoClobber', 'Append', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','NoClobber','Append','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaDuplicateIndex.Tests.ps1 b/tests/Find-DbaDuplicateIndex.Tests.ps1 index 6df8025dda..d5db9257f4 100644 --- a/tests/Find-DbaDuplicateIndex.Tests.ps1 +++ b/tests/Find-DbaDuplicateIndex.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaDuplicateIndex).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'IncludeOverlapping', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','IncludeOverlapping','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaInstance.Tests.ps1 b/tests/Find-DbaInstance.Tests.ps1 index b6a56057ab..129cfe443b 100644 --- a/tests/Find-DbaInstance.Tests.ps1 +++ b/tests/Find-DbaInstance.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaInstance).Parameters.Keys - $knownParameters = 'ComputerName', 'DiscoveryType', 'Credential', 'SqlCredential', 'ScanType', 'IpAddress', 'DomainController', 'TCPPort', 'MinimumConfidence', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','DiscoveryType','Credential','SqlCredential','ScanType','IpAddress','DomainController','TCPPort','MinimumConfidence','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaLoginInGroup.Tests.ps1 b/tests/Find-DbaLoginInGroup.Tests.ps1 index 8c6f627e5a..3c781e6d55 100644 --- a/tests/Find-DbaLoginInGroup.Tests.ps1 +++ b/tests/Find-DbaLoginInGroup.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaLoginInGroup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaOrphanedFile.Tests.ps1 b/tests/Find-DbaOrphanedFile.Tests.ps1 index 6692a9e9fd..6a61b9bdd6 100644 --- a/tests/Find-DbaOrphanedFile.Tests.ps1 +++ b/tests/Find-DbaOrphanedFile.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaOrphanedFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'FileType', 'LocalOnly', 'RemoteOnly', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','FileType','LocalOnly','RemoteOnly','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaSimilarTable.Tests.ps1 b/tests/Find-DbaSimilarTable.Tests.ps1 index 238e080cd8..dd770f6a89 100644 --- a/tests/Find-DbaSimilarTable.Tests.ps1 +++ b/tests/Find-DbaSimilarTable.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaSimilarTable).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'SchemaName', 'TableName', 'ExcludeViews', 'IncludeSystemDatabases', 'MatchPercentThreshold', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','SchemaName','TableName','ExcludeViews','IncludeSystemDatabases','MatchPercentThreshold','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaStoredProcedure.Tests.ps1 b/tests/Find-DbaStoredProcedure.Tests.ps1 index abca884fcc..857dfad513 100644 --- a/tests/Find-DbaStoredProcedure.Tests.ps1 +++ b/tests/Find-DbaStoredProcedure.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaStoredProcedure).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Pattern', 'IncludeSystemObjects', 'IncludeSystemDatabases', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Pattern','IncludeSystemObjects','IncludeSystemDatabases','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaTrigger.Tests.ps1 b/tests/Find-DbaTrigger.Tests.ps1 index e64f24e55a..c921ce3f32 100644 --- a/tests/Find-DbaTrigger.Tests.ps1 +++ b/tests/Find-DbaTrigger.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaTrigger).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Pattern', 'TriggerLevel', 'IncludeSystemObjects', 'IncludeSystemDatabases', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Pattern','TriggerLevel','IncludeSystemObjects','IncludeSystemDatabases','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaUserObject.Tests.ps1 b/tests/Find-DbaUserObject.Tests.ps1 index 3bd5e4f0b3..e222eb6df9 100644 --- a/tests/Find-DbaUserObject.Tests.ps1 +++ b/tests/Find-DbaUserObject.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaUserObject).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Pattern', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Pattern','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Find-DbaView.Tests.ps1 b/tests/Find-DbaView.Tests.ps1 index bb10c78875..857dfad513 100644 --- a/tests/Find-DbaView.Tests.ps1 +++ b/tests/Find-DbaView.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Find-DbaView).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Pattern', 'IncludeSystemObjects', 'IncludeSystemDatabases', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Pattern','IncludeSystemObjects','IncludeSystemDatabases','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Format-DbaBackupInformation.Tests.ps1 b/tests/Format-DbaBackupInformation.Tests.ps1 index 6ad605bdad..0eb7ae11f3 100644 --- a/tests/Format-DbaBackupInformation.Tests.ps1 +++ b/tests/Format-DbaBackupInformation.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 14 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Format-DbaBackupInformation).Parameters.Keys - $knownParameters = 'BackupHistory', 'ReplaceDatabaseName', 'ReplaceDbNameInFile', 'DataFileDirectory', 'LogFileDirectory', 'DestinationFileStreamDirectory', 'DatabaseNamePrefix', 'DatabaseFilePrefix', 'DatabaseFileSuffix', 'RebaseBackupFolder', 'Continue', 'FileMapping', 'PathSep', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'BackupHistory','ReplaceDatabaseName','ReplaceDbNameInFile','DataFileDirectory','LogFileDirectory','DestinationFileStreamDirectory','DatabaseNamePrefix','DatabaseFilePrefix','DatabaseFileSuffix','RebaseBackupFolder','Continue','FileMapping','PathSep','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgDatabase.Tests.ps1 b/tests/Get-DbaAgDatabase.Tests.ps1 index 3f33deae91..bf6d3cf26f 100644 --- a/tests/Get-DbaAgDatabase.Tests.ps1 +++ b/tests/Get-DbaAgDatabase.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Database', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Database','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgHadr.Tests.ps1 b/tests/Get-DbaAgHadr.Tests.ps1 index 0676c0200d..47f07f29b2 100644 --- a/tests/Get-DbaAgHadr.Tests.ps1 +++ b/tests/Get-DbaAgHadr.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgHadr).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contian our specifc parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgListener.Tests.ps1 b/tests/Get-DbaAgListener.Tests.ps1 index ff5879d2c6..1e04da91c5 100644 --- a/tests/Get-DbaAgListener.Tests.ps1 +++ b/tests/Get-DbaAgListener.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgListener).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Listener', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Listener','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgReplica.Tests.ps1 b/tests/Get-DbaAgReplica.Tests.ps1 index 48ec7e4911..6b2c84c95e 100644 --- a/tests/Get-DbaAgReplica.Tests.ps1 +++ b/tests/Get-DbaAgReplica.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgReplica).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Replica', 'EnableException', 'InputObject' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Replica','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentAlert.Tests.ps1 b/tests/Get-DbaAgentAlert.Tests.ps1 index 3d58fdbe24..d1520ff74a 100644 --- a/tests/Get-DbaAgentAlert.Tests.ps1 +++ b/tests/Get-DbaAgentAlert.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentAlert).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentJob.Tests.ps1 b/tests/Get-DbaAgentJob.Tests.ps1 index 6e11b6dd27..13a95a16fd 100644 --- a/tests/Get-DbaAgentJob.Tests.ps1 +++ b/tests/Get-DbaAgentJob.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'ExcludeDisabledJobs', 'EnableException', 'Database', 'Category' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','Database','Category','ExcludeDisabledJobs','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentJobCategory.Tests.ps1 b/tests/Get-DbaAgentJobCategory.Tests.ps1 index 143404400e..3b2e020903 100644 --- a/tests/Get-DbaAgentJobCategory.Tests.ps1 +++ b/tests/Get-DbaAgentJobCategory.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentJobCategory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Category', 'CategoryType', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Category','CategoryType','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentJobHistory.Tests.ps1 b/tests/Get-DbaAgentJobHistory.Tests.ps1 index 60a128f3b6..e351f953ec 100644 --- a/tests/Get-DbaAgentJobHistory.Tests.ps1 +++ b/tests/Get-DbaAgentJobHistory.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentJobHistory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'StartDate', 'EndDate', 'ExcludeJobSteps', 'WithOutputFile', 'JobCollection', 'EnableException' - It "Contains our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','StartDate','EndDate','ExcludeJobSteps','WithOutputFile','JobCollection','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentJobOutputFile.Tests.ps1 b/tests/Get-DbaAgentJobOutputFile.Tests.ps1 index 895f906fd0..82b1cb5098 100644 --- a/tests/Get-DbaAgentJobOutputFile.Tests.ps1 +++ b/tests/Get-DbaAgentJobOutputFile.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentJobOutputFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'EnableException' - It "Contains our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentJobStep.Tests.ps1 b/tests/Get-DbaAgentJobStep.Tests.ps1 index 82667f5e8d..da460cafb6 100644 --- a/tests/Get-DbaAgentJobStep.Tests.ps1 +++ b/tests/Get-DbaAgentJobStep.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentJobStep).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'EnableException' - It "Contains our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','ExcludeDisabledJobs','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentLog.Tests.ps1 b/tests/Get-DbaAgentLog.Tests.ps1 index 9a645b9b4c..0ff85390b7 100644 --- a/tests/Get-DbaAgentLog.Tests.ps1 +++ b/tests/Get-DbaAgentLog.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentLog).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'LogNumber', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','LogNumber','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentOperator.Tests.ps1 b/tests/Get-DbaAgentOperator.Tests.ps1 index 434287d6b8..906ae0b285 100644 --- a/tests/Get-DbaAgentOperator.Tests.ps1 +++ b/tests/Get-DbaAgentOperator.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentOperator).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Operator', 'ExcludeOperator', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Operator','ExcludeOperator','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentProxy.Tests.ps1 b/tests/Get-DbaAgentProxy.Tests.ps1 index 65a42e9407..57b4222dc3 100644 --- a/tests/Get-DbaAgentProxy.Tests.ps1 +++ b/tests/Get-DbaAgentProxy.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentProxy).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Proxy', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Proxy','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentSchedule.Tests.ps1 b/tests/Get-DbaAgentSchedule.Tests.ps1 index e939583e57..33e306951f 100644 --- a/tests/Get-DbaAgentSchedule.Tests.ps1 +++ b/tests/Get-DbaAgentSchedule.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentSchedule).Parameters.Keys - $knownParameters = 'SqlInstance', 'Schedule', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Schedule','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAgentServer.Tests.ps1 b/tests/Get-DbaAgentServer.Tests.ps1 index 4908146361..86d298d57e 100644 --- a/tests/Get-DbaAgentServer.Tests.ps1 +++ b/tests/Get-DbaAgentServer.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentServer).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAvailabilityGroup.Tests.ps1 b/tests/Get-DbaAvailabilityGroup.Tests.ps1 index 4f46aa106b..3754c25a23 100644 --- a/tests/Get-DbaAvailabilityGroup.Tests.ps1 +++ b/tests/Get-DbaAvailabilityGroup.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAvailabilityGroup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'IsPrimary', 'EnableException' - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','IsPrimary','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaAvailableCollation.Tests.ps1 b/tests/Get-DbaAvailableCollation.Tests.ps1 index 49c2828611..1491b5d063 100644 --- a/tests/Get-DbaAvailableCollation.Tests.ps1 +++ b/tests/Get-DbaAvailableCollation.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAvailableCollation).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaBackupDevice.Tests.ps1 b/tests/Get-DbaBackupDevice.Tests.ps1 index 846b4d2b07..696c5bc3d2 100644 --- a/tests/Get-DbaBackupDevice.Tests.ps1 +++ b/tests/Get-DbaBackupDevice.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaBackupDevice).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaBackupHistory.Tests.ps1 b/tests/Get-DbaBackupHistory.Tests.ps1 index 2c9d8c9f18..9eaa5b2417 100644 --- a/tests/Get-DbaBackupHistory.Tests.ps1 +++ b/tests/Get-DbaBackupHistory.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaBackupHistory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IncludeCopyOnly', 'Force', 'Since', 'Last', 'LastFull', 'LastDiff', 'LastLog', 'DeviceType', 'Raw', 'LastLsn', 'Type', 'EnableException', 'RecoveryFork' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeCopyOnly','Force','Since','RecoveryFork','Last','LastFull','LastDiff','LastLog','DeviceType','Raw','LastLsn','Type','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaBackupInformation.Tests.ps1 b/tests/Get-DbaBackupInformation.Tests.ps1 index 72998ce230..8e2e6de667 100644 --- a/tests/Get-DbaBackupInformation.Tests.ps1 +++ b/tests/Get-DbaBackupInformation.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaBackupInformation).Parameters.Keys - $knownParameters = 'Path', 'SqlInstance', 'SqlCredential', 'DatabaseName', 'SourceInstance', 'NoXpDirTree', 'DirectoryRecurse', 'EnableException', 'MaintenanceSolution', 'IgnoreLogBackup', 'ExportPath', 'AzureCredential', 'Import', 'Anonymise', 'NoClobber', 'PassThru' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','SqlInstance','SqlCredential','DatabaseName','SourceInstance','NoXpDirTree','DirectoryRecurse','EnableException','MaintenanceSolution','IgnoreLogBackup','ExportPath','AzureCredential','Import','Anonymise','NoClobber','PassThru' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaBuildReference.Tests.ps1 b/tests/Get-DbaBuildReference.Tests.ps1 index 7ca3d0ef0d..3e09ed4d5e 100644 --- a/tests/Get-DbaBuildReference.Tests.ps1 +++ b/tests/Get-DbaBuildReference.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaBuildReference).Parameters.Keys - $knownParameters = 'Build', 'SqlInstance', 'SqlCredential', 'Update', 'EnableException','KB','MajorVersion','ServicePack','CumulativeUpdate' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Build','Kb','MajorVersion','ServicePack','CumulativeUpdate','SqlInstance','SqlCredential','Update','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaClientAlias.Tests.ps1 b/tests/Get-DbaClientAlias.Tests.ps1 index d0d79bef50..9b201a40de 100644 --- a/tests/Get-DbaClientAlias.Tests.ps1 +++ b/tests/Get-DbaClientAlias.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaClientAlias).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaClientProtocol.Tests.ps1 b/tests/Get-DbaClientProtocol.Tests.ps1 index 541e0c7bbe..8deb241256 100644 --- a/tests/Get-DbaClientProtocol.Tests.ps1 +++ b/tests/Get-DbaClientProtocol.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaClientProtocol).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaClusterAvailableDisk.Tests.ps1 b/tests/Get-DbaClusterAvailableDisk.Tests.ps1 deleted file mode 100644 index a3475e4270..0000000000 --- a/tests/Get-DbaClusterAvailableDisk.Tests.ps1 +++ /dev/null @@ -1,13 +0,0 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") -Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan -. "$PSScriptRoot\constants.ps1" - -Describe "$CommandName Unit Tests" -Tag 'UnitTests' { - Context "Validate parameters" { - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcAvailableDisk).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count - } - } -} \ No newline at end of file diff --git a/tests/Get-DbaCmConnection.Tests.ps1 b/tests/Get-DbaCmConnection.Tests.ps1 index 7950c51c5f..6dbebed4ae 100644 --- a/tests/Get-DbaCmConnection.Tests.ps1 +++ b/tests/Get-DbaCmConnection.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaCmConnection).Parameters.Keys - $knownParameters = 'ComputerName', 'UserName', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','UserName','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCmObject.Tests.ps1 b/tests/Get-DbaCmObject.Tests.ps1 index ad11150e60..9e705a6a73 100644 --- a/tests/Get-DbaCmObject.Tests.ps1 +++ b/tests/Get-DbaCmObject.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaCmObject).Parameters.Keys - $knownParameters = 'ClassName', 'Query', 'ComputerName', 'Credential', 'Namespace', 'DoNotUse', 'Force', 'SilentlyContinue', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ClassName','Query','ComputerName','Credential','Namespace','DoNotUse','Force','SilentlyContinue','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCmsRegServer.Tests.ps1 b/tests/Get-DbaCmsRegServer.Tests.ps1 index c85677f82f..06445fcc02 100644 --- a/tests/Get-DbaCmsRegServer.Tests.ps1 +++ b/tests/Get-DbaCmsRegServer.Tests.ps1 @@ -4,12 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'ServerName', 'Group', 'ExcludeGroup', 'Id', 'IncludeSelf', 'ExcludeCmsServer', 'ResolveNetworkName', 'EnableException' - $SupportShouldProcess = $false - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','ServerName','Group','ExcludeGroup','Id','IncludeSelf','ExcludeCmsServer','ResolveNetworkName','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCmsRegServerGroup.Tests.ps1 b/tests/Get-DbaCmsRegServerGroup.Tests.ps1 index 4450f6f24f..241ebc04f4 100644 --- a/tests/Get-DbaCmsRegServerGroup.Tests.ps1 +++ b/tests/Get-DbaCmsRegServerGroup.Tests.ps1 @@ -4,12 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Group', 'ExcludeGroup', 'Id', 'EnableException' - $SupportShouldProcess = $false - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Group','ExcludeGroup','Id','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCmsRegServerStore.Tests.ps1 b/tests/Get-DbaCmsRegServerStore.Tests.ps1 index 59d3464c32..8ada6809d9 100644 --- a/tests/Get-DbaCmsRegServerStore.Tests.ps1 +++ b/tests/Get-DbaCmsRegServerStore.Tests.ps1 @@ -4,12 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - $SupportShouldProcess = $false - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaComputerCertificate.Tests.ps1 b/tests/Get-DbaComputerCertificate.Tests.ps1 index b6bef00785..b6e7742ea1 100644 --- a/tests/Get-DbaComputerCertificate.Tests.ps1 +++ b/tests/Get-DbaComputerCertificate.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaComputerCertificate).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Store', 'Folder', 'Path', 'Thumbprint', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Store','Folder','Path','Thumbprint','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaComputerSystem.Tests.ps1 b/tests/Get-DbaComputerSystem.Tests.ps1 index c074f3cd09..a120f1204e 100644 --- a/tests/Get-DbaComputerSystem.Tests.ps1 +++ b/tests/Get-DbaComputerSystem.Tests.ps1 @@ -1,25 +1,20 @@ $CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" + Describe "Get-DbaComputerSystem Unit Tests" -Tag "UnitTests" { - InModuleScope dbatools { - Context "Validate parameters" { - $params = (Get-ChildItem function:\Get-DbaComputerSystem).Parameters - it "should have a parameter named ComputerName" { - $params.ContainsKey("ComputerName") | Should Be $true - } - it "should have a parameter named Credential" { - $params.ContainsKey("Credential") | Should Be $true - } - it "should have a parameter named EnableException" { - $params.ContainsKey("EnableException") | Should Be $true - } + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','IncludeAws','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } - Context "Validate input" { - it "Cannot resolve hostname of computer" { - mock Resolve-DbaNetworkName {$null} - {Get-DbaComputerSystem -ComputerName 'DoesNotExist142' -WarningAction Stop 3> $null} | Should Throw - } + } + Context "Validate input" { + it "Cannot resolve hostname of computer" { + mock Resolve-DbaNetworkName {$null} + {Get-DbaComputerSystem -ComputerName 'DoesNotExist142' -WarningAction Stop 3> $null} | Should Throw } } } diff --git a/tests/Get-DbaConnection.Tests.ps1 b/tests/Get-DbaConnection.Tests.ps1 index ce21f3729a..9477e2a532 100644 --- a/tests/Get-DbaConnection.Tests.ps1 +++ b/tests/Get-DbaConnection.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaConnection).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCpuRingBuffer.Tests.ps1 b/tests/Get-DbaCpuRingBuffer.Tests.ps1 index 82faf4bd13..41e9b30633 100644 --- a/tests/Get-DbaCpuRingBuffer.Tests.ps1 +++ b/tests/Get-DbaCpuRingBuffer.Tests.ps1 @@ -4,12 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'CollectionMinutes', 'EnableException' - $SupportShouldProcess = $false - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','CollectionMinutes','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCpuUsage.Tests.ps1 b/tests/Get-DbaCpuUsage.Tests.ps1 index 021a296cb3..69c77d4cd5 100644 --- a/tests/Get-DbaCpuUsage.Tests.ps1 +++ b/tests/Get-DbaCpuUsage.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaCpuUsage).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'Threshold', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','Threshold','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCredential.Tests.ps1 b/tests/Get-DbaCredential.Tests.ps1 index 8c5facee94..387b230605 100644 --- a/tests/Get-DbaCredential.Tests.ps1 +++ b/tests/Get-DbaCredential.Tests.ps1 @@ -6,10 +6,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaCredential).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'ExcludeName', 'Identity', 'ExcludeIdentity', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','ExcludeName','Identity','ExcludeIdentity','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaCustomError.Tests.ps1 b/tests/Get-DbaCustomError.Tests.ps1 index 2d58420bc5..32b994f471 100644 --- a/tests/Get-DbaCustomError.Tests.ps1 +++ b/tests/Get-DbaCustomError.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaCustomError).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDatabase.Tests.ps1 b/tests/Get-DbaDatabase.Tests.ps1 index bf9b6334b2..8475c6459f 100644 --- a/tests/Get-DbaDatabase.Tests.ps1 +++ b/tests/Get-DbaDatabase.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeUser', 'ExcludeSystem', 'Owner', 'Encrypted', 'Status', 'Access', 'RecoveryModel', 'NoFullBackup', 'NoFullBackupSince', 'NoLogBackup', 'NoLogBackupSince', 'EnableException', 'IncludeLastUsed', 'OnlyAccessible' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeUser','ExcludeSystem','Owner','Encrypted','Status','Access','RecoveryModel','NoFullBackup','NoFullBackupSince','NoLogBackup','NoLogBackupSince','EnableException','IncludeLastUsed','OnlyAccessible' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbAssembly.Tests.ps1 b/tests/Get-DbaDbAssembly.Tests.ps1 index 85dc896696..d7a0c4d95c 100644 --- a/tests/Get-DbaDbAssembly.Tests.ps1 +++ b/tests/Get-DbaDbAssembly.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbAssembly).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbCertificate.Tests.ps1 b/tests/Get-DbaDbCertificate.Tests.ps1 index fcfeeaa8c1..a12c689530 100644 --- a/tests/Get-DbaDbCertificate.Tests.ps1 +++ b/tests/Get-DbaDbCertificate.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbCertificate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Certificate', 'InputObject', 'Subject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Certificate','Subject','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbCheckConstraint.Tests.ps1 b/tests/Get-DbaDbCheckConstraint.Tests.ps1 index 6f31c0451a..b83558d47b 100644 --- a/tests/Get-DbaDbCheckConstraint.Tests.ps1 +++ b/tests/Get-DbaDbCheckConstraint.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbCheckConstraint).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeSystemTable', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeSystemTable','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbCompatibility.Tests.ps1 b/tests/Get-DbaDbCompatibility.Tests.ps1 index 1f2c214029..b66ae02e74 100644 --- a/tests/Get-DbaDbCompatibility.Tests.ps1 +++ b/tests/Get-DbaDbCompatibility.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbCompatibility).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbCompression.Tests.ps1 b/tests/Get-DbaDbCompression.Tests.ps1 index b0d0e6e03e..a5415cb3f0 100644 --- a/tests/Get-DbaDbCompression.Tests.ps1 +++ b/tests/Get-DbaDbCompression.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbCompression).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbDbccOpenTran.Tests.ps1 b/tests/Get-DbaDbDbccOpenTran.Tests.ps1 index cb968c3d12..bb8445305f 100644 --- a/tests/Get-DbaDbDbccOpenTran.Tests.ps1 +++ b/tests/Get-DbaDbDbccOpenTran.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbEncryption.Tests.ps1 b/tests/Get-DbaDbEncryption.Tests.ps1 index fb3958e6b2..dd6364da41 100644 --- a/tests/Get-DbaDbEncryption.Tests.ps1 +++ b/tests/Get-DbaDbEncryption.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbEncryption).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IncludeSystemDBs', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeSystemDBs','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbExtentDiff.Tests.ps1 b/tests/Get-DbaDbExtentDiff.Tests.ps1 index fa4ef6e85b..5370762095 100644 --- a/tests/Get-DbaDbExtentDiff.Tests.ps1 +++ b/tests/Get-DbaDbExtentDiff.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbExtentDiff).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbFeatureUsage.Tests.ps1 b/tests/Get-DbaDbFeatureUsage.Tests.ps1 index c227645462..a058a98197 100644 --- a/tests/Get-DbaDbFeatureUsage.Tests.ps1 +++ b/tests/Get-DbaDbFeatureUsage.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbFeatureUsage).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbFile.Tests.ps1 b/tests/Get-DbaDbFile.Tests.ps1 index 51cd503818..442ba45a5c 100644 --- a/tests/Get-DbaDbFile.Tests.ps1 +++ b/tests/Get-DbaDbFile.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbForeignKey.Tests.ps1 b/tests/Get-DbaDbForeignKey.Tests.ps1 index a6f2f3905b..58eba571fe 100644 --- a/tests/Get-DbaDbForeignKey.Tests.ps1 +++ b/tests/Get-DbaDbForeignKey.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbForeignKey).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeSystemTable', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeSystemTable','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbLogShipError.Tests.ps1 b/tests/Get-DbaDbLogShipError.Tests.ps1 index fc72c3c358..fb043a8776 100644 --- a/tests/Get-DbaDbLogShipError.Tests.ps1 +++ b/tests/Get-DbaDbLogShipError.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaAgentJobStep).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'EnableException' - It "Contains our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Action','DateTimeFrom','DateTimeTo','Primary','Secondary','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMail.Tests.ps1 b/tests/Get-DbaDbMail.Tests.ps1 index 14e27500bc..c5b69228ef 100644 --- a/tests/Get-DbaDbMail.Tests.ps1 +++ b/tests/Get-DbaDbMail.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMail).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMailAccount.Tests.ps1 b/tests/Get-DbaDbMailAccount.Tests.ps1 index ef709c2b3b..d7c65bea01 100644 --- a/tests/Get-DbaDbMailAccount.Tests.ps1 +++ b/tests/Get-DbaDbMailAccount.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMailAccount).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Account', 'ExcludeAccount', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Account','ExcludeAccount','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMailConfig.Tests.ps1 b/tests/Get-DbaDbMailConfig.Tests.ps1 index 12548a2a0c..979441cc8c 100644 --- a/tests/Get-DbaDbMailConfig.Tests.ps1 +++ b/tests/Get-DbaDbMailConfig.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMailConfig).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMailHistory.Tests.ps1 b/tests/Get-DbaDbMailHistory.Tests.ps1 index ca0c1d7cb8..b344cc59f7 100644 --- a/tests/Get-DbaDbMailHistory.Tests.ps1 +++ b/tests/Get-DbaDbMailHistory.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMailHistory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Since', 'Status', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Since','Status','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMailLog.Tests.ps1 b/tests/Get-DbaDbMailLog.Tests.ps1 index a4b1745493..6518ae234f 100644 --- a/tests/Get-DbaDbMailLog.Tests.ps1 +++ b/tests/Get-DbaDbMailLog.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMailLog).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Since', 'Type', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Since','Type','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMailProfile.Tests.ps1 b/tests/Get-DbaDbMailProfile.Tests.ps1 index e0a474c10c..934ff07771 100644 --- a/tests/Get-DbaDbMailProfile.Tests.ps1 +++ b/tests/Get-DbaDbMailProfile.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMailProfile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Profile', 'ExcludeProfile', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Profile','ExcludeProfile','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMailServer.Tests.ps1 b/tests/Get-DbaDbMailServer.Tests.ps1 index 818376b1e0..a4e2c0f68a 100644 --- a/tests/Get-DbaDbMailServer.Tests.ps1 +++ b/tests/Get-DbaDbMailServer.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMailServer).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Server', 'Account', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Server','Account','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMasterKey.Tests.ps1 b/tests/Get-DbaDbMasterKey.Tests.ps1 index d81207792d..fd4cea80e3 100644 --- a/tests/Get-DbaDbMasterKey.Tests.ps1 +++ b/tests/Get-DbaDbMasterKey.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMasterKey).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMemoryUsage.Tests.ps1 b/tests/Get-DbaDbMemoryUsage.Tests.ps1 index c14318f408..6a8875e8cf 100644 --- a/tests/Get-DbaDbMemoryUsage.Tests.ps1 +++ b/tests/Get-DbaDbMemoryUsage.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException', 'IncludeSystemDb', 'Database', 'ExcludeDatabase' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeSystemDb','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMirror.Tests.ps1 b/tests/Get-DbaDbMirror.Tests.ps1 index 64fc490b17..a323cc8501 100644 --- a/tests/Get-DbaDbMirror.Tests.ps1 +++ b/tests/Get-DbaDbMirror.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMirror).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbMirrorMonitor.Tests.ps1 b/tests/Get-DbaDbMirrorMonitor.Tests.ps1 index 6af7907c7d..bb467725bd 100644 --- a/tests/Get-DbaDbMirrorMonitor.Tests.ps1 +++ b/tests/Get-DbaDbMirrorMonitor.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbMirrorMonitor).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'Update', 'LimitResults', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','Update','LimitResults','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbOrphanUser.Tests.ps1 b/tests/Get-DbaDbOrphanUser.Tests.ps1 index ce9b45ef7f..5eaca98a6b 100644 --- a/tests/Get-DbaDbOrphanUser.Tests.ps1 +++ b/tests/Get-DbaDbOrphanUser.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbOrphanUser).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbPageInfo.Tests.ps1 b/tests/Get-DbaDbPageInfo.Tests.ps1 index 20a662f682..11d53e583c 100644 --- a/tests/Get-DbaDbPageInfo.Tests.ps1 +++ b/tests/Get-DbaDbPageInfo.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbPageInfo).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Schema', 'Table', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Schema','Table','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbPartitionFunction.Tests.ps1 b/tests/Get-DbaDbPartitionFunction.Tests.ps1 index bcc924a99a..540c681608 100644 --- a/tests/Get-DbaDbPartitionFunction.Tests.ps1 +++ b/tests/Get-DbaDbPartitionFunction.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbPartitionFunction).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbPartitionScheme.Tests.ps1 b/tests/Get-DbaDbPartitionScheme.Tests.ps1 index 928509718e..562b886049 100644 --- a/tests/Get-DbaDbPartitionScheme.Tests.ps1 +++ b/tests/Get-DbaDbPartitionScheme.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbPartitionScheme).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbQueryStoreOption.Tests.ps1 b/tests/Get-DbaDbQueryStoreOption.Tests.ps1 index 34eeafbe7c..d57274dd02 100644 --- a/tests/Get-DbaDbQueryStoreOption.Tests.ps1 +++ b/tests/Get-DbaDbQueryStoreOption.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbQueryStoreOption).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbRecoveryModel.Tests.ps1 b/tests/Get-DbaDbRecoveryModel.Tests.ps1 index 4751559bd3..a7bc7750e5 100644 --- a/tests/Get-DbaDbRecoveryModel.Tests.ps1 +++ b/tests/Get-DbaDbRecoveryModel.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbRecoveryModel).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'RecoveryModel', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','RecoveryModel','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbRestoreHistory.Tests.ps1 b/tests/Get-DbaDbRestoreHistory.Tests.ps1 index 9c76fa92e1..8203e1b61c 100644 --- a/tests/Get-DbaDbRestoreHistory.Tests.ps1 +++ b/tests/Get-DbaDbRestoreHistory.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbRestoreHistory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Since', 'Last', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Since','Force','Last','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } diff --git a/tests/Get-DbaDbRoleMember.Tests.ps1 b/tests/Get-DbaDbRoleMember.Tests.ps1 index 0ddbfb9a1d..eb9faaafb5 100644 --- a/tests/Get-DbaDbRoleMember.Tests.ps1 +++ b/tests/Get-DbaDbRoleMember.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbRoleMember).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException', 'Database', 'ExcludeDatabase', 'ExcludeFixedRole', 'Role', 'ExcludeRole', 'IncludeSystemUser' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Role','ExcludeRole','ExcludeFixedRole','IncludeSystemUser','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbSharePoint.Tests.ps1 b/tests/Get-DbaDbSharePoint.Tests.ps1 index fcf53f5413..bd8711d7ce 100644 --- a/tests/Get-DbaDbSharePoint.Tests.ps1 +++ b/tests/Get-DbaDbSharePoint.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbSharePoint).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'ConfigDatabase', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','ConfigDatabase','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbSnapshot.Tests.ps1 b/tests/Get-DbaDbSnapshot.Tests.ps1 index 0414dbd7e9..1dd284c3a1 100644 --- a/tests/Get-DbaDbSnapshot.Tests.ps1 +++ b/tests/Get-DbaDbSnapshot.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbSnapshot).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Snapshot', 'ExcludeSnapshot', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Snapshot','ExcludeSnapshot','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbSpace.Tests.ps1 b/tests/Get-DbaDbSpace.Tests.ps1 index 174a2e49d5..a001d5c161 100644 --- a/tests/Get-DbaDbSpace.Tests.ps1 +++ b/tests/Get-DbaDbSpace.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbSpace).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'InputObject', 'Database', 'ExcludeDatabase', 'IncludeSystemDBs', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeSystemDBs','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbState.Tests.ps1 b/tests/Get-DbaDbState.Tests.ps1 index 9ee940cd41..141e18e64f 100644 --- a/tests/Get-DbaDbState.Tests.ps1 +++ b/tests/Get-DbaDbState.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbState).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbStoredProcedure.Tests.ps1 b/tests/Get-DbaDbStoredProcedure.Tests.ps1 index abc051cf66..f5ac4f20e8 100644 --- a/tests/Get-DbaDbStoredProcedure.Tests.ps1 +++ b/tests/Get-DbaDbStoredProcedure.Tests.ps1 @@ -10,10 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbStoredProcedure).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeSystemSp', 'EnableException' - it "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeSystemSp','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbTable.Tests.ps1 b/tests/Get-DbaDbTable.Tests.ps1 index d8e7bd8696..1446c8905d 100644 --- a/tests/Get-DbaDbTable.Tests.ps1 +++ b/tests/Get-DbaDbTable.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbTable).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IncludeSystemDBs', 'Table', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeSystemDBs','Table','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbTrigger.Tests.ps1 b/tests/Get-DbaDbTrigger.Tests.ps1 index 7c03c7b2fd..0fac453c4f 100644 --- a/tests/Get-DbaDbTrigger.Tests.ps1 +++ b/tests/Get-DbaDbTrigger.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbTrigger).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbUdf.Tests.ps1 b/tests/Get-DbaDbUdf.Tests.ps1 index 39dd7803a3..23b4354fb1 100644 --- a/tests/Get-DbaDbUdf.Tests.ps1 +++ b/tests/Get-DbaDbUdf.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbUdf).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeSystemUdf', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeSystemUdf','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbUser.Tests.ps1 b/tests/Get-DbaDbUser.Tests.ps1 index a42b79f55f..26c90cd3ac 100644 --- a/tests/Get-DbaDbUser.Tests.ps1 +++ b/tests/Get-DbaDbUser.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbUser).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeSystemUser', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeSystemUser','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbView.Tests.ps1 b/tests/Get-DbaDbView.Tests.ps1 index 20107221b3..d12ee92ee8 100644 --- a/tests/Get-DbaDbView.Tests.ps1 +++ b/tests/Get-DbaDbView.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbView).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeSystemView', 'EnableException' - it "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeSystemView','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbVirtualLogFile.Tests.ps1 b/tests/Get-DbaDbVirtualLogFile.Tests.ps1 index 838968c615..23dd2488c0 100644 --- a/tests/Get-DbaDbVirtualLogFile.Tests.ps1 +++ b/tests/Get-DbaDbVirtualLogFile.Tests.ps1 @@ -10,10 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDbVirtualLogFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IncludeSystemDbs', 'EnableException' - it "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeSystemDBs','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbccHelp.Tests.ps1 b/tests/Get-DbaDbccHelp.Tests.ps1 index feb1d64cca..95c67715f0 100644 --- a/tests/Get-DbaDbccHelp.Tests.ps1 +++ b/tests/Get-DbaDbccHelp.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Statement', 'IncludeUndocumented', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Statement','IncludeUndocumented','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbccMemoryStatus.Tests.ps1 b/tests/Get-DbaDbccMemoryStatus.Tests.ps1 index 468bb20a5d..c76fef7520 100644 --- a/tests/Get-DbaDbccMemoryStatus.Tests.ps1 +++ b/tests/Get-DbaDbccMemoryStatus.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbccProcCache.Tests.ps1 b/tests/Get-DbaDbccProcCache.Tests.ps1 index ab6d990ba0..f5abc507df 100644 --- a/tests/Get-DbaDbccProcCache.Tests.ps1 +++ b/tests/Get-DbaDbccProcCache.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbccSessionBuffer.Tests.ps1 b/tests/Get-DbaDbccSessionBuffer.Tests.ps1 index eea0848ad1..57b19bc908 100644 --- a/tests/Get-DbaDbccSessionBuffer.Tests.ps1 +++ b/tests/Get-DbaDbccSessionBuffer.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Operation', 'SessionId', 'RequestId', 'All', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Operation','SessionId','RequestId','All','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbccStatistic.Tests.ps1 b/tests/Get-DbaDbccStatistic.Tests.ps1 index 68d71c55c0..184c06e3cd 100644 --- a/tests/Get-DbaDbccStatistic.Tests.ps1 +++ b/tests/Get-DbaDbccStatistic.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Object', 'Target', 'Option', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Object','Target','Option','NoInformationalMessages','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDbccUserOption.Tests.ps1 b/tests/Get-DbaDbccUserOption.Tests.ps1 index 2c8bebdc7a..18d0b034e5 100644 --- a/tests/Get-DbaDbccUserOption.Tests.ps1 +++ b/tests/Get-DbaDbccUserOption.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Option', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Option','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDefaultPath.Tests.ps1 b/tests/Get-DbaDefaultPath.Tests.ps1 index e93085f891..3e29ed5927 100644 --- a/tests/Get-DbaDefaultPath.Tests.ps1 +++ b/tests/Get-DbaDefaultPath.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDefaultPath).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDependency.Tests.ps1 b/tests/Get-DbaDependency.Tests.ps1 index b05c4fc43d..6b5a1c307d 100644 --- a/tests/Get-DbaDependency.Tests.ps1 +++ b/tests/Get-DbaDependency.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDependency).Parameters.Keys - $knownParameters = 'InputObject', 'AllowSystemObjects', 'Parents', 'IncludeSelf', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','AllowSystemObjects','Parents','IncludeSelf','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDeprecatedFeature.Tests.ps1 b/tests/Get-DbaDeprecatedFeature.Tests.ps1 index 0d3a0aa614..8609d60742 100644 --- a/tests/Get-DbaDeprecatedFeature.Tests.ps1 +++ b/tests/Get-DbaDeprecatedFeature.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDeprecatedFeature).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDetachedDatabaseInfo.Tests.ps1 b/tests/Get-DbaDetachedDatabaseInfo.Tests.ps1 index 62cc7cb80c..6a89111eac 100644 --- a/tests/Get-DbaDetachedDatabaseInfo.Tests.ps1 +++ b/tests/Get-DbaDetachedDatabaseInfo.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDetachedDatabaseInfo).Parameters.Keys - $knownParameters = 'SqlInstance', 'Path', 'SqlCredential' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Path','SqlCredential' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDiskSpace.Tests.ps1 b/tests/Get-DbaDiskSpace.Tests.ps1 index ac72e95747..5a3cda5616 100644 --- a/tests/Get-DbaDiskSpace.Tests.ps1 +++ b/tests/Get-DbaDiskSpace.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaDiskSpace).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Unit', 'CheckForSql', 'SqlCredential', 'ExcludeDrive', 'CheckFragmentation', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Unit','CheckForSql','SqlCredential','ExcludeDrive','CheckFragmentation','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaDump.Tests.ps1 b/tests/Get-DbaDump.Tests.ps1 index 56a0634e51..45538439c1 100644 --- a/tests/Get-DbaDump.Tests.ps1 +++ b/tests/Get-DbaDump.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaEndpoint.Tests.ps1 b/tests/Get-DbaEndpoint.Tests.ps1 index 9754244c4a..da1c5141a2 100644 --- a/tests/Get-DbaEndpoint.Tests.ps1 +++ b/tests/Get-DbaEndpoint.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaEndpoint).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Endpoint', 'EnableException', 'Type' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Endpoint','Type','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaErrorLog.Tests.ps1 b/tests/Get-DbaErrorLog.Tests.ps1 index 500334d59c..98fc1525b4 100644 --- a/tests/Get-DbaErrorLog.Tests.ps1 +++ b/tests/Get-DbaErrorLog.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaErrorLog).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'LogNumber', 'Source', 'Text', 'After', 'Before', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','LogNumber','Source','Text','After','Before','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaErrorLogConfig.Tests.ps1 b/tests/Get-DbaErrorLogConfig.Tests.ps1 index 82bbc5084a..53c1226d16 100644 --- a/tests/Get-DbaErrorLogConfig.Tests.ps1 +++ b/tests/Get-DbaErrorLogConfig.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaErrorLogConfig).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should -Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 b/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 index d4bafb7b99..0082fc21c9 100644 --- a/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 +++ b/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaEstimatedCompletionTime).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaExecutionPlan.Tests.ps1 b/tests/Get-DbaExecutionPlan.Tests.ps1 index 83dcf3bb7d..c94e07386b 100644 --- a/tests/Get-DbaExecutionPlan.Tests.ps1 +++ b/tests/Get-DbaExecutionPlan.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaExecutionPlan).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'SinceCreation', 'SinceLastExecution', 'ExcludeEmptyQueryPlan', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','SinceCreation','SinceLastExecution','ExcludeEmptyQueryPlan','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaFeature.Tests.ps1 b/tests/Get-DbaFeature.Tests.ps1 index 72bcfb13d0..08a19ea48f 100644 --- a/tests/Get-DbaFeature.Tests.ps1 +++ b/tests/Get-DbaFeature.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaFeature).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaFile.Tests.ps1 b/tests/Get-DbaFile.Tests.ps1 index 9c673be0b2..e0101b8477 100644 --- a/tests/Get-DbaFile.Tests.ps1 +++ b/tests/Get-DbaFile.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'FileType', 'Depth', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','FileType','Depth','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaFilestream.Tests.ps1 b/tests/Get-DbaFilestream.Tests.ps1 index aa5319f980..3dd0188872 100644 --- a/tests/Get-DbaFilestream.Tests.ps1 +++ b/tests/Get-DbaFilestream.Tests.ps1 @@ -10,10 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaFilestream).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaForceNetworkEncryption.Tests.ps1 b/tests/Get-DbaForceNetworkEncryption.Tests.ps1 index 47e5b5fd6e..cb51c19527 100644 --- a/tests/Get-DbaForceNetworkEncryption.Tests.ps1 +++ b/tests/Get-DbaForceNetworkEncryption.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaForceNetworkEncryption).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaHelpIndex.Tests.ps1 b/tests/Get-DbaHelpIndex.Tests.ps1 index f9d529998a..91dfd0e2f1 100644 --- a/tests/Get-DbaHelpIndex.Tests.ps1 +++ b/tests/Get-DbaHelpIndex.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\$CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'InputObject', 'ObjectName', 'IncludeStats', 'IncludeDataTypes', 'Raw', 'IncludeFragmentation', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','InputObject','ObjectName','IncludeStats','IncludeDataTypes','Raw','IncludeFragmentation','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaInstanceProperty.Tests.ps1 b/tests/Get-DbaInstanceProperty.Tests.ps1 index f5edd32d2d..5ed20a5002 100644 --- a/tests/Get-DbaInstanceProperty.Tests.ps1 +++ b/tests/Get-DbaInstanceProperty.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaInstanceProperty).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'InstanceProperty', 'ExcludeInstanceProperty', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','InstanceProperty','ExcludeInstanceProperty','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaInstanceUserOption.Tests.ps1 b/tests/Get-DbaInstanceUserOption.Tests.ps1 index 39ddff5789..ba58e4e91c 100644 --- a/tests/Get-DbaInstanceUserOption.Tests.ps1 +++ b/tests/Get-DbaInstanceUserOption.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaInstanceUserOption).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaIoLatency.Tests.ps1 b/tests/Get-DbaIoLatency.Tests.ps1 index da24067eb1..64a8eb11f0 100644 --- a/tests/Get-DbaIoLatency.Tests.ps1 +++ b/tests/Get-DbaIoLatency.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - $paramCount = $knownParameters.Count - $SupportShouldProcess = $false - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaLastBackup.Tests.ps1 b/tests/Get-DbaLastBackup.Tests.ps1 index 99b1da52fe..bcf8453e71 100644 --- a/tests/Get-DbaLastBackup.Tests.ps1 +++ b/tests/Get-DbaLastBackup.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaLastBackup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaLastGoodCheckDb.Tests.ps1 b/tests/Get-DbaLastGoodCheckDb.Tests.ps1 index 6bb7bd8ddb..03227bbc77 100644 --- a/tests/Get-DbaLastGoodCheckDb.Tests.ps1 +++ b/tests/Get-DbaLastGoodCheckDb.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaLastGoodCheckDb).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaLatchStatistic.Tests.ps1 b/tests/Get-DbaLatchStatistic.Tests.ps1 index 8f9f8bae3b..32cd69bc92 100644 --- a/tests/Get-DbaLatchStatistic.Tests.ps1 +++ b/tests/Get-DbaLatchStatistic.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Threshold', 'EnableException' - $paramCount = $knownParameters.Count - $SupportShouldProcess = $false - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Threshold','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaLinkedServer.Tests.ps1 b/tests/Get-DbaLinkedServer.Tests.ps1 index 0a1aad80cd..5c0bcb3475 100644 --- a/tests/Get-DbaLinkedServer.Tests.ps1 +++ b/tests/Get-DbaLinkedServer.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaLinkedServer).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'LinkedServer', 'ExcludeLinkedServer', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','LinkedServer','ExcludeLinkedServer','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaLocaleSetting.Tests.ps1 b/tests/Get-DbaLocaleSetting.Tests.ps1 index d40f75f182..c3d2147a9d 100644 --- a/tests/Get-DbaLocaleSetting.Tests.ps1 +++ b/tests/Get-DbaLocaleSetting.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaLocaleSetting).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaLogin.Tests.ps1 b/tests/Get-DbaLogin.Tests.ps1 index 66fb51412b..c5723b0525 100644 --- a/tests/Get-DbaLogin.Tests.ps1 +++ b/tests/Get-DbaLogin.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'SQLLogins', 'WindowsLogins', 'Login', 'IncludeFilter', 'ExcludeLogin', 'ExcludeFilter', 'ExcludeSystemLogin', 'Type', 'HasAccess', 'Locked', 'Disabled', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','IncludeFilter','ExcludeLogin','ExcludeFilter','ExcludeSystemLogin','Type','HasAccess','SqlLogins','WindowsLogins','Locked','Disabled','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaMaintenanceSolutionLog.Tests.ps1 b/tests/Get-DbaMaintenanceSolutionLog.Tests.ps1 index 2708ab155b..00efc7b7c2 100644 --- a/tests/Get-DbaMaintenanceSolutionLog.Tests.ps1 +++ b/tests/Get-DbaMaintenanceSolutionLog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaMaintenanceSolutionLog).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'LogType', 'Since', 'Path', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','LogType','Since','Path','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaManagementObject.Tests.ps1 b/tests/Get-DbaManagementObject.Tests.ps1 index 1e84a7c9d9..1eecd6de96 100644 --- a/tests/Get-DbaManagementObject.Tests.ps1 +++ b/tests/Get-DbaManagementObject.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaManagementObject).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'VersionNumber', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','VersionNumber','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaMaxMemory.Tests.ps1 b/tests/Get-DbaMaxMemory.Tests.ps1 index 3ebde64f97..c81c0f8582 100644 --- a/tests/Get-DbaMaxMemory.Tests.ps1 +++ b/tests/Get-DbaMaxMemory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaMaxMemory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaMemoryCondition.Tests.ps1 b/tests/Get-DbaMemoryCondition.Tests.ps1 index ae1fa20d08..945ec08f6e 100644 --- a/tests/Get-DbaMemoryCondition.Tests.ps1 +++ b/tests/Get-DbaMemoryCondition.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaMemoryCondition).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaMemoryUsage.Tests.ps1 b/tests/Get-DbaMemoryUsage.Tests.ps1 index 2f1f1d6fe9..8e7bd7b7bb 100644 --- a/tests/Get-DbaMemoryUsage.Tests.ps1 +++ b/tests/Get-DbaMemoryUsage.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaMemoryUsage).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaModule.Tests.ps1 b/tests/Get-DbaModule.Tests.ps1 index f9fd6d3448..4fa094fa86 100644 --- a/tests/Get-DbaModule.Tests.ps1 +++ b/tests/Get-DbaModule.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaModule).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ModifiedSince', 'Type', 'ExcludeSystemDatabases', 'ExcludeSystemObjects', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ModifiedSince','Type','ExcludeSystemDatabases','ExcludeSystemObjects','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaMsdtc.Tests.ps1 b/tests/Get-DbaMsdtc.Tests.ps1 index 227d6fef73..ee71be7e53 100644 --- a/tests/Get-DbaMsdtc.Tests.ps1 +++ b/tests/Get-DbaMsdtc.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 1 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaMsdtc).Parameters.Keys - $knownParameters = 'ComputerName' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==" | Measure-Object ).Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaNetworkActivity.Tests.ps1 b/tests/Get-DbaNetworkActivity.Tests.ps1 index dd03829b90..1a8e816eda 100644 --- a/tests/Get-DbaNetworkActivity.Tests.ps1 +++ b/tests/Get-DbaNetworkActivity.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaNetworkActivity).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaNetworkCertificate.Tests.ps1 b/tests/Get-DbaNetworkCertificate.Tests.ps1 index f45790231f..0c3d42c1d6 100644 --- a/tests/Get-DbaNetworkCertificate.Tests.ps1 +++ b/tests/Get-DbaNetworkCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaNetworkCertificate).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaOpenTransaction.Tests.ps1 b/tests/Get-DbaOpenTransaction.Tests.ps1 index 2ac103204b..973f4b929d 100644 --- a/tests/Get-DbaOpenTransaction.Tests.ps1 +++ b/tests/Get-DbaOpenTransaction.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaOpenTransaction).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaOperatingSystem.Tests.ps1 b/tests/Get-DbaOperatingSystem.Tests.ps1 index 3c0386fe25..4db5e2bc35 100644 --- a/tests/Get-DbaOperatingSystem.Tests.ps1 +++ b/tests/Get-DbaOperatingSystem.Tests.ps1 @@ -4,22 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - $SupportShouldProcess = $false - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } Context "Validate input" { diff --git a/tests/Get-DbaPageFileSetting.Tests.ps1 b/tests/Get-DbaPageFileSetting.Tests.ps1 index 5dabae28cb..4d4498a6f6 100644 --- a/tests/Get-DbaPageFileSetting.Tests.ps1 +++ b/tests/Get-DbaPageFileSetting.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPageFileSetting).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPbmCategory.Tests.ps1 b/tests/Get-DbaPbmCategory.Tests.ps1 index 332bf8a4b0..c8789af7e8 100644 --- a/tests/Get-DbaPbmCategory.Tests.ps1 +++ b/tests/Get-DbaPbmCategory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPbmCategory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Category', 'InputObject', 'ExcludeSystemObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Category','InputObject','ExcludeSystemObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPbmCategorySubscription.Tests.ps1 b/tests/Get-DbaPbmCategorySubscription.Tests.ps1 index 06c879fdb4..b1a1cb7bfb 100644 --- a/tests/Get-DbaPbmCategorySubscription.Tests.ps1 +++ b/tests/Get-DbaPbmCategorySubscription.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPbmCategorySubscription).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPbmCondition.Tests.ps1 b/tests/Get-DbaPbmCondition.Tests.ps1 index 0a11689636..fd966da42d 100644 --- a/tests/Get-DbaPbmCondition.Tests.ps1 +++ b/tests/Get-DbaPbmCondition.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPbmCondition).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Condition', 'InputObject', 'IncludeSystemObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Condition','InputObject','IncludeSystemObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPbmObjectSet.Tests.ps1 b/tests/Get-DbaPbmObjectSet.Tests.ps1 index bf8521dc39..0984e96f01 100644 --- a/tests/Get-DbaPbmObjectSet.Tests.ps1 +++ b/tests/Get-DbaPbmObjectSet.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPbmObjectSet).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'ObjectSet', 'InputObject', 'IncludeSystemObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','ObjectSet','InputObject','IncludeSystemObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPbmPolicy.Tests.ps1 b/tests/Get-DbaPbmPolicy.Tests.ps1 index 26f4bc112c..fa75c9cd4f 100644 --- a/tests/Get-DbaPbmPolicy.Tests.ps1 +++ b/tests/Get-DbaPbmPolicy.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPbmPolicy).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Policy', 'Category', 'InputObject', 'IncludeSystemObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Policy','Category','InputObject','IncludeSystemObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPbmStore.Tests.ps1 b/tests/Get-DbaPbmStore.Tests.ps1 index 3ef078730c..a323cc8501 100644 --- a/tests/Get-DbaPbmStore.Tests.ps1 +++ b/tests/Get-DbaPbmStore.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPbmStore).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPermission.Tests.ps1 b/tests/Get-DbaPermission.Tests.ps1 index e782599b92..0911596cd6 100644 --- a/tests/Get-DbaPermission.Tests.ps1 +++ b/tests/Get-DbaPermission.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPermission).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IncludeServerLevel', 'ExcludeSystemObjects', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeServerLevel','ExcludeSystemObjects','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPfAvailableCounter.Tests.ps1 b/tests/Get-DbaPfAvailableCounter.Tests.ps1 index 15ec00f9d9..01e2f87849 100644 --- a/tests/Get-DbaPfAvailableCounter.Tests.ps1 +++ b/tests/Get-DbaPfAvailableCounter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPfAvailableCounter).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Pattern', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Pattern','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPfDataCollector.Tests.ps1 b/tests/Get-DbaPfDataCollector.Tests.ps1 index 03d014c89c..4e510ea185 100644 --- a/tests/Get-DbaPfDataCollector.Tests.ps1 +++ b/tests/Get-DbaPfDataCollector.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPfDataCollector).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'Collector', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','Collector','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPfDataCollectorCounter.Tests.ps1 b/tests/Get-DbaPfDataCollectorCounter.Tests.ps1 index 5cb5754223..909cd24a2b 100644 --- a/tests/Get-DbaPfDataCollectorCounter.Tests.ps1 +++ b/tests/Get-DbaPfDataCollectorCounter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPfDataCollectorCounter).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'Collector', 'Counter', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','Collector','Counter','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPfDataCollectorCounterSample.Tests.ps1 b/tests/Get-DbaPfDataCollectorCounterSample.Tests.ps1 index fc87d9f6f0..41999f1359 100644 --- a/tests/Get-DbaPfDataCollectorCounterSample.Tests.ps1 +++ b/tests/Get-DbaPfDataCollectorCounterSample.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 11 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPfDataCollectorCounterSample).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'Collector', 'Counter', 'Continuous', 'ListSet', 'MaxSamples', 'SampleInterval', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','Collector','Counter','Continuous','ListSet','MaxSamples','SampleInterval','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPfDataCollectorSet.Tests.ps1 b/tests/Get-DbaPfDataCollectorSet.Tests.ps1 index 834552d119..3a36dcaf43 100644 --- a/tests/Get-DbaPfDataCollectorSet.Tests.ps1 +++ b/tests/Get-DbaPfDataCollectorSet.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPfDataCollectorSet).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPfDataCollectorSetTemplate.Tests.ps1 b/tests/Get-DbaPfDataCollectorSetTemplate.Tests.ps1 index 8fe4162051..6593dec705 100644 --- a/tests/Get-DbaPfDataCollectorSetTemplate.Tests.ps1 +++ b/tests/Get-DbaPfDataCollectorSetTemplate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPfDataCollectorSetTemplate).Parameters.Keys - $knownParameters = 'Path', 'Pattern', 'Template', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','Pattern','Template','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPlanCache.Tests.ps1 b/tests/Get-DbaPlanCache.Tests.ps1 index 00b33ae17c..7e89e11232 100644 --- a/tests/Get-DbaPlanCache.Tests.ps1 +++ b/tests/Get-DbaPlanCache.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPlanCache).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPowerPlan.Tests.ps1 b/tests/Get-DbaPowerPlan.Tests.ps1 index 177fb3b07d..654ae76992 100644 --- a/tests/Get-DbaPowerPlan.Tests.ps1 +++ b/tests/Get-DbaPowerPlan.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPowerPlan).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaPrivilege.Tests.ps1 b/tests/Get-DbaPrivilege.Tests.ps1 index e5a91cbb4a..a4b8af3e9b 100644 --- a/tests/Get-DbaPrivilege.Tests.ps1 +++ b/tests/Get-DbaPrivilege.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaPrivilege).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaProcess.Tests.ps1 b/tests/Get-DbaProcess.Tests.ps1 index 2134fd927a..13e8ce5cc0 100644 --- a/tests/Get-DbaProcess.Tests.ps1 +++ b/tests/Get-DbaProcess.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaProcess).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Spid', 'ExcludeSpid', 'Database', 'Login', 'Hostname', 'Program', 'ExcludeSystemSpids', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Spid','ExcludeSpid','Database','Login','Hostname','Program','ExcludeSystemSpids','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaProductKey.Tests.ps1 b/tests/Get-DbaProductKey.Tests.ps1 index 4772489b5f..c44561efa0 100644 --- a/tests/Get-DbaProductKey.Tests.ps1 +++ b/tests/Get-DbaProductKey.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaProductKey).Parameters.Keys - $knownParameters = 'ComputerName', 'SqlCredential', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','SqlCredential','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaQueryExecutionTime.Tests.ps1 b/tests/Get-DbaQueryExecutionTime.Tests.ps1 index fa69313fe1..a21b24fc71 100644 --- a/tests/Get-DbaQueryExecutionTime.Tests.ps1 +++ b/tests/Get-DbaQueryExecutionTime.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaQueryExecutionTime).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'MaxResultsPerDb', 'MinExecs', 'MinExecMs', 'ExcludeSystem', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','MaxResultsPerDb','MinExecs','MinExecMs','ExcludeSystem','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaRegistryRoot.Tests.ps1 b/tests/Get-DbaRegistryRoot.Tests.ps1 index 04c4bdca31..31f0124424 100644 --- a/tests/Get-DbaRegistryRoot.Tests.ps1 +++ b/tests/Get-DbaRegistryRoot.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaRegistryRoot).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaRepDistributor.Tests.ps1 b/tests/Get-DbaRepDistributor.Tests.ps1 index a3490ff08b..fb273fcb20 100644 --- a/tests/Get-DbaRepDistributor.Tests.ps1 +++ b/tests/Get-DbaRepDistributor.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaRepDistributor).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaRepPublication.Tests.ps1 b/tests/Get-DbaRepPublication.Tests.ps1 index e0f7421ec0..54dcf1f242 100644 --- a/tests/Get-DbaRepPublication.Tests.ps1 +++ b/tests/Get-DbaRepPublication.Tests.ps1 @@ -4,26 +4,16 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\..\internal\functions\Connect-SqlInstance.ps1" Describe "$commandname Unit Tests" -Tag 'UnitTests' { - - InModuleScope dbatools { - - Context "Parameter Validation" { - - [object[]]$params = (Get-ChildItem function:\Get-DbaRepPublication).Parameters.Keys - $knownParameters = 'SqlInstance', 'Database', 'SqlCredential', 'PublicationType', 'EnableException' - $paramCount = $knownParameters.Count - $defaultParamCount = $params.Count - $paramCount - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount - } - + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Database','SqlCredential','PublicationType','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } + } + InModuleScope dbatools { Context "Code Validation" { Mock Connect-ReplicationDB -MockWith { diff --git a/tests/Get-DbaRepServer.Tests.ps1 b/tests/Get-DbaRepServer.Tests.ps1 index 47b0afc303..a323cc8501 100644 --- a/tests/Get-DbaRepServer.Tests.ps1 +++ b/tests/Get-DbaRepServer.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaRepServer).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaResourceGovernor.Tests.ps1 b/tests/Get-DbaResourceGovernor.Tests.ps1 index a1671a33ba..a323cc8501 100644 --- a/tests/Get-DbaResourceGovernor.Tests.ps1 +++ b/tests/Get-DbaResourceGovernor.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaResourceGovernor).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaRgClassifierFunction.Tests.ps1 b/tests/Get-DbaRgClassifierFunction.Tests.ps1 index 46b70e4273..7e07203e79 100644 --- a/tests/Get-DbaRgClassifierFunction.Tests.ps1 +++ b/tests/Get-DbaRgClassifierFunction.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaRgClassifierFunction).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaRgResourcePool.Tests.ps1 b/tests/Get-DbaRgResourcePool.Tests.ps1 index 00d3134f86..5f1480eed8 100644 --- a/tests/Get-DbaRgResourcePool.Tests.ps1 +++ b/tests/Get-DbaRgResourcePool.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaRgResourcePool).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Type', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Type','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaRgWorkloadGroup.Tests.ps1 b/tests/Get-DbaRgWorkloadGroup.Tests.ps1 index bdddb7ec51..b1a1cb7bfb 100644 --- a/tests/Get-DbaRgWorkloadGroup.Tests.ps1 +++ b/tests/Get-DbaRgWorkloadGroup.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaRgWorkloadGroup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaRunningJob.Tests.ps1 b/tests/Get-DbaRunningJob.Tests.ps1 index 081d85f1b7..b1a1cb7bfb 100644 --- a/tests/Get-DbaRunningJob.Tests.ps1 +++ b/tests/Get-DbaRunningJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaRunningJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaSchemaChangeHistory.Tests.ps1 b/tests/Get-DbaSchemaChangeHistory.Tests.ps1 index 561256c456..9f2a34bcd6 100644 --- a/tests/Get-DbaSchemaChangeHistory.Tests.ps1 +++ b/tests/Get-DbaSchemaChangeHistory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaSchemaChangeHistory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Since', 'Object', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Since','Object','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaServerAudit.Tests.ps1 b/tests/Get-DbaServerAudit.Tests.ps1 index 8eef49eac9..68df9104e4 100644 --- a/tests/Get-DbaServerAudit.Tests.ps1 +++ b/tests/Get-DbaServerAudit.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaServerAudit).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Audit', 'ExcludeAudit', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Audit','ExcludeAudit','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaServerAuditSpecification.Tests.ps1 b/tests/Get-DbaServerAuditSpecification.Tests.ps1 index aac1c93ca0..a323cc8501 100644 --- a/tests/Get-DbaServerAuditSpecification.Tests.ps1 +++ b/tests/Get-DbaServerAuditSpecification.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaServerAuditSpecification).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaServerInstallDate.Tests.ps1 b/tests/Get-DbaServerInstallDate.Tests.ps1 index df4ce8b67e..0b12b91354 100644 --- a/tests/Get-DbaServerInstallDate.Tests.ps1 +++ b/tests/Get-DbaServerInstallDate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaServerInstallDate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'IncludeWindows', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','IncludeWindows','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaServerProtocol.Tests.ps1 b/tests/Get-DbaServerProtocol.Tests.ps1 index 485a689fbd..91a4b24133 100644 --- a/tests/Get-DbaServerProtocol.Tests.ps1 +++ b/tests/Get-DbaServerProtocol.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaServerProtocol).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaServerRole.Tests.ps1 b/tests/Get-DbaServerRole.Tests.ps1 index c8f3f0ab66..705894c43a 100644 --- a/tests/Get-DbaServerRole.Tests.ps1 +++ b/tests/Get-DbaServerRole.Tests.ps1 @@ -10,22 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaServerRole).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException', 'ServerRole', 'ExcludeServerRole', 'ExcludeFixedRole' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','ServerRole','ExcludeServerRole','ExcludeFixedRole','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } Context "Input validation" { diff --git a/tests/Get-DbaServerRoleMember.Tests.ps1 b/tests/Get-DbaServerRoleMember.Tests.ps1 index c21544165e..519aec24c3 100644 --- a/tests/Get-DbaServerRoleMember.Tests.ps1 +++ b/tests/Get-DbaServerRoleMember.Tests.ps1 @@ -4,18 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $defaultParamCount = 11 - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException', 'ExcludeFixedRole', 'ServerRole', 'ExcludeServerRole', 'Login' - $paramCount = $knownParameters.Count - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','ServerRole','ExcludeServerRole','Login','ExcludeFixedRole','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaServerTrigger.Tests.ps1 b/tests/Get-DbaServerTrigger.Tests.ps1 index 1d55767002..a323cc8501 100644 --- a/tests/Get-DbaServerTrigger.Tests.ps1 +++ b/tests/Get-DbaServerTrigger.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaServerTrigger).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaService.Tests.ps1 b/tests/Get-DbaService.Tests.ps1 index f349029b38..2e0971b622 100644 --- a/tests/Get-DbaService.Tests.ps1 +++ b/tests/Get-DbaService.Tests.ps1 @@ -5,21 +5,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $knownParameters = 'ComputerName', 'InstanceName', 'Credential', 'Type', 'ServiceName', 'AdvancedProperties', 'EnableException' - $paramCount = $knownParameters.Count - $SupportShouldProcess = $false - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - [object[]]$params = (Get-ChildItem function:\Get-DbaService).Parameters.Keys - - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','InstanceName','Credential','Type','ServiceName','AdvancedProperties','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } diff --git a/tests/Get-DbaSpConfigure.Tests.ps1 b/tests/Get-DbaSpConfigure.Tests.ps1 index 7e3430a356..a0ddf3db5b 100644 --- a/tests/Get-DbaSpConfigure.Tests.ps1 +++ b/tests/Get-DbaSpConfigure.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaSpConfigure).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'ExcludeName', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','ExcludeName','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaSpinLockStatistic.Tests.ps1 b/tests/Get-DbaSpinLockStatistic.Tests.ps1 index 938d4a80f1..86f8752c3a 100644 --- a/tests/Get-DbaSpinLockStatistic.Tests.ps1 +++ b/tests/Get-DbaSpinLockStatistic.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - $paramCount = $knownParameters.Count - $SupportShouldProcess = $false - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaSpn.Tests.ps1 b/tests/Get-DbaSpn.Tests.ps1 index 6955490218..40cb1feb62 100644 --- a/tests/Get-DbaSpn.Tests.ps1 +++ b/tests/Get-DbaSpn.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaSpn).Parameters.Keys - $knownParameters = 'ComputerName', 'AccountName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','AccountName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaSsisEnvironmentVariable.Tests.ps1 b/tests/Get-DbaSsisEnvironmentVariable.Tests.ps1 index 445d34c366..1be6117f03 100644 --- a/tests/Get-DbaSsisEnvironmentVariable.Tests.ps1 +++ b/tests/Get-DbaSsisEnvironmentVariable.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaSsisEnvironmentVariable).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Environment', 'EnvironmentExclude', 'Folder', 'FolderExclude', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Environment','EnvironmentExclude','Folder','FolderExclude','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaSsisExecutionHistory.Tests.ps1 b/tests/Get-DbaSsisExecutionHistory.Tests.ps1 index 1720d33dcc..c4e319bc18 100644 --- a/tests/Get-DbaSsisExecutionHistory.Tests.ps1 +++ b/tests/Get-DbaSsisExecutionHistory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaSsisExecutionHistory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Since', 'Status', 'Project', 'Folder', 'Environment', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Since','Status','Project','Folder','Environment','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaStartupParameter.Tests.ps1 b/tests/Get-DbaStartupParameter.Tests.ps1 index b4b145e1c4..b6533ca12e 100644 --- a/tests/Get-DbaStartupParameter.Tests.ps1 +++ b/tests/Get-DbaStartupParameter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaStartupParameter).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'Simple', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','Simple','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaSuspectPage.Tests.ps1 b/tests/Get-DbaSuspectPage.Tests.ps1 index 14b91b45f2..87f52d123d 100644 --- a/tests/Get-DbaSuspectPage.Tests.ps1 +++ b/tests/Get-DbaSuspectPage.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaSuspectPage).Parameters.Keys - $knownParameters = 'SqlInstance', 'Database', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Database','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaTcpPort.Tests.ps1 b/tests/Get-DbaTcpPort.Tests.ps1 index 1705e7cd68..0b01b2e093 100644 --- a/tests/Get-DbaTcpPort.Tests.ps1 +++ b/tests/Get-DbaTcpPort.Tests.ps1 @@ -4,22 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaTcpPort).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'All', 'ExcludeIpv6', 'EnableException', 'Detailed' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Detailed','All','ExcludeIpv6','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaTempdbUsage.Tests.ps1 b/tests/Get-DbaTempdbUsage.Tests.ps1 index 87fb48b1d4..a323cc8501 100644 --- a/tests/Get-DbaTempdbUsage.Tests.ps1 +++ b/tests/Get-DbaTempdbUsage.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaTempdbUsage).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaTopResourceUsage.Tests.ps1 b/tests/Get-DbaTopResourceUsage.Tests.ps1 index dcc99f215b..b530603dbd 100644 --- a/tests/Get-DbaTopResourceUsage.Tests.ps1 +++ b/tests/Get-DbaTopResourceUsage.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaTopResourceUsage).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Type', 'Limit', 'EnableException', 'ExcludeSystem' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Type','Limit','EnableException','ExcludeSystem' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaTrace.Tests.ps1 b/tests/Get-DbaTrace.Tests.ps1 index 8e3cc3a831..e675bda4dc 100644 --- a/tests/Get-DbaTrace.Tests.ps1 +++ b/tests/Get-DbaTrace.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaTrace).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Id', 'Default', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Id','Default','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaTraceFlag.Tests.ps1 b/tests/Get-DbaTraceFlag.Tests.ps1 index fcbdb66388..cd7f627a44 100644 --- a/tests/Get-DbaTraceFlag.Tests.ps1 +++ b/tests/Get-DbaTraceFlag.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem Function:\Get-DbaTraceFlag).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} - [object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'TraceFlag', 'EnableException' + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','TraceFlag','EnableException' $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters It "Should only contain our specific parameters" { - (@(Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params).Count ) | Should Be 0 + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaUpTime.Tests.ps1 b/tests/Get-DbaUpTime.Tests.ps1 index da78af0ce2..3d96bb9bd3 100644 --- a/tests/Get-DbaUpTime.Tests.ps1 +++ b/tests/Get-DbaUpTime.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaUptime).Parameters.Keys - $knownParameters = 'Computer', 'SqlInstance', 'SqlCredential', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaUserPermission.Tests.ps1 b/tests/Get-DbaUserPermission.Tests.ps1 index 531c33c1c5..2596f5b952 100644 --- a/tests/Get-DbaUserPermission.Tests.ps1 +++ b/tests/Get-DbaUserPermission.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Get-DbaUserPermission).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'ExcludeSystemDatabase', 'IncludePublicGuest', 'IncludeSystemObjects', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','ExcludeSystemDatabase','IncludePublicGuest','IncludeSystemObjects','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaWaitResource.Tests.ps1 b/tests/Get-DbaWaitResource.Tests.ps1 index c515986768..68a6821aeb 100644 --- a/tests/Get-DbaWaitResource.Tests.ps1 +++ b/tests/Get-DbaWaitResource.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaWaitResource).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'WaitResource', 'Row', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','WaitResource','Row','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaWaitStatistic.Tests.ps1 b/tests/Get-DbaWaitStatistic.Tests.ps1 index 1c27eaad72..c9e22c509e 100644 --- a/tests/Get-DbaWaitStatistic.Tests.ps1 +++ b/tests/Get-DbaWaitStatistic.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaWaitStatistic).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Threshold', 'IncludeIgnorable', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Threshold','IncludeIgnorable','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaWaitingTask.Tests.ps1 b/tests/Get-DbaWaitingTask.Tests.ps1 index df8f9c2472..2177a66082 100644 --- a/tests/Get-DbaWaitingTask.Tests.ps1 +++ b/tests/Get-DbaWaitingTask.Tests.ps1 @@ -10,16 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaWaitingTask).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException', 'Spid', 'IncludeSystemSpid' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Spid','IncludeSystemSpid','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaWindowsLog.Tests.ps1 b/tests/Get-DbaWindowsLog.Tests.ps1 index 0e22ef98d4..616438548d 100644 --- a/tests/Get-DbaWindowsLog.Tests.ps1 +++ b/tests/Get-DbaWindowsLog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaWindowsLog).Parameters.Keys - $knownParameters = 'SqlInstance', 'Start', 'End', 'Credential', 'MaxThreads', 'MaxRemoteThreads', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Start','End','Credential','MaxThreads','MaxRemoteThreads','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaWsfcAvailableDisk.Tests.ps1 b/tests/Get-DbaWsfcAvailableDisk.Tests.ps1 index da493e5b98..37a09c7680 100644 --- a/tests/Get-DbaWsfcAvailableDisk.Tests.ps1 +++ b/tests/Get-DbaWsfcAvailableDisk.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcAvailableDisk).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcCluster.Tests.ps1 b/tests/Get-DbaWsfcCluster.Tests.ps1 index 4263846857..37a09c7680 100644 --- a/tests/Get-DbaWsfcCluster.Tests.ps1 +++ b/tests/Get-DbaWsfcCluster.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcCluster).Parameters.Keys - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcDisk.Tests.ps1 b/tests/Get-DbaWsfcDisk.Tests.ps1 index 96a143fe61..37a09c7680 100644 --- a/tests/Get-DbaWsfcDisk.Tests.ps1 +++ b/tests/Get-DbaWsfcDisk.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcDisk).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcNetwork.Tests.ps1 b/tests/Get-DbaWsfcNetwork.Tests.ps1 index 41b16b33cf..37a09c7680 100644 --- a/tests/Get-DbaWsfcNetwork.Tests.ps1 +++ b/tests/Get-DbaWsfcNetwork.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcNetwork).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcNetworkInterface.Tests.ps1 b/tests/Get-DbaWsfcNetworkInterface.Tests.ps1 index 40737756d0..37a09c7680 100644 --- a/tests/Get-DbaWsfcNetworkInterface.Tests.ps1 +++ b/tests/Get-DbaWsfcNetworkInterface.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcNetworkInterface).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcNode.Tests.ps1 b/tests/Get-DbaWsfcNode.Tests.ps1 index 3334dfe369..37a09c7680 100644 --- a/tests/Get-DbaWsfcNode.Tests.ps1 +++ b/tests/Get-DbaWsfcNode.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcNode).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcResource.Tests.ps1 b/tests/Get-DbaWsfcResource.Tests.ps1 index ff96ed0a3f..37a09c7680 100644 --- a/tests/Get-DbaWsfcResource.Tests.ps1 +++ b/tests/Get-DbaWsfcResource.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcResource).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcResourceType.Tests.ps1 b/tests/Get-DbaWsfcResourceType.Tests.ps1 index bfd394869b..37a09c7680 100644 --- a/tests/Get-DbaWsfcResourceType.Tests.ps1 +++ b/tests/Get-DbaWsfcResourceType.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcResourceType).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcRole.Tests.ps1 b/tests/Get-DbaWsfcRole.Tests.ps1 index e575168263..37a09c7680 100644 --- a/tests/Get-DbaWsfcRole.Tests.ps1 +++ b/tests/Get-DbaWsfcRole.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcRole).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaWsfcSharedVolume.Tests.ps1 b/tests/Get-DbaWsfcSharedVolume.Tests.ps1 index 8c4cb91ae6..37a09c7680 100644 --- a/tests/Get-DbaWsfcSharedVolume.Tests.ps1 +++ b/tests/Get-DbaWsfcSharedVolume.Tests.ps1 @@ -4,24 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - $paramCount = $knownParameters.Count - - [object[]]$params = (Get-ChildItem function:\Get-DbaWsfcSharedVolume).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Get-DbaXEObject.Tests.ps1 b/tests/Get-DbaXEObject.Tests.ps1 index 896ee875f7..5a614559dd 100644 --- a/tests/Get-DbaXEObject.Tests.ps1 +++ b/tests/Get-DbaXEObject.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaXEObject).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Type', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Type','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaXESession.Tests.ps1 b/tests/Get-DbaXESession.Tests.ps1 index d0f39c79e2..08d398a7b7 100644 --- a/tests/Get-DbaXESession.Tests.ps1 +++ b/tests/Get-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaXESession).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Session', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Session','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaXESessionTarget.Tests.ps1 b/tests/Get-DbaXESessionTarget.Tests.ps1 index 108a6e99bd..9b8814e003 100644 --- a/tests/Get-DbaXESessionTarget.Tests.ps1 +++ b/tests/Get-DbaXESessionTarget.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaXESessionTarget).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Session', 'Target', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Session','Target','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaXESessionTemplate.Tests.ps1 b/tests/Get-DbaXESessionTemplate.Tests.ps1 index fc5d80be6b..dcc2c47764 100644 --- a/tests/Get-DbaXESessionTemplate.Tests.ps1 +++ b/tests/Get-DbaXESessionTemplate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaXESessionTemplate).Parameters.Keys - $knownParameters = 'Path', 'Pattern', 'Template', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','Pattern','Template','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaXESmartTarget.Tests.ps1 b/tests/Get-DbaXESmartTarget.Tests.ps1 index 5011504816..4ee0be1275 100644 --- a/tests/Get-DbaXESmartTarget.Tests.ps1 +++ b/tests/Get-DbaXESmartTarget.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 1 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaXESmartTarget).Parameters.Keys - $knownParameters = 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==" | Measure-Object ).Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbaXEStore.Tests.ps1 b/tests/Get-DbaXEStore.Tests.ps1 index b544f658b1..a323cc8501 100644 --- a/tests/Get-DbaXEStore.Tests.ps1 +++ b/tests/Get-DbaXEStore.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbaXEStore).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbatoolsConfig.Tests.ps1 b/tests/Get-DbatoolsConfig.Tests.ps1 index cd4c0bc171..93d39ef21a 100644 --- a/tests/Get-DbatoolsConfig.Tests.ps1 +++ b/tests/Get-DbatoolsConfig.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbatoolsConfig).Parameters.Keys - $knownParameters = 'FullName', 'Name', 'Module', 'Force' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'FullName','Name','Module','Force' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbatoolsConfigValue.Tests.ps1 b/tests/Get-DbatoolsConfigValue.Tests.ps1 index 9fab6e2971..08af9875cd 100644 --- a/tests/Get-DbatoolsConfigValue.Tests.ps1 +++ b/tests/Get-DbatoolsConfigValue.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbatoolsConfigValue).Parameters.Keys - $knownParameters = 'FullName', 'Fallback', 'NotNull' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'FullName','Fallback','NotNull' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DbatoolsLog.Tests.ps1 b/tests/Get-DbatoolsLog.Tests.ps1 index 45a48a73e1..6257756818 100644 --- a/tests/Get-DbatoolsLog.Tests.ps1 +++ b/tests/Get-DbatoolsLog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DbatoolsLog).Parameters.Keys - $knownParameters = 'FunctionName', 'ModuleName', 'Target', 'Tag', 'Last', 'Skip', 'Runspace', 'Level', 'Errors', 'Raw' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'FunctionName','ModuleName','Target','Tag','Last','Skip','Runspace','Level','Raw','Errors' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Get-DirectoryRestoreFile.Tests.ps1 b/tests/Get-DirectoryRestoreFile.Tests.ps1 index 8705bcfe9b..e2c94c14fc 100644 --- a/tests/Get-DirectoryRestoreFile.Tests.ps1 +++ b/tests/Get-DirectoryRestoreFile.Tests.ps1 @@ -5,19 +5,17 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Get-DirectoryRestoreFile).Parameters.Keys - $knownParameters = 'Path', 'Recurse', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path', 'Recurse', 'EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } +} - Context "Test Path handling" { +Describe "$CommandName Integration Tests" -Tag 'IntegrationTests' { + Context "Test Path handling" { It "Should throw on an invalid Path" { { Get-DirectoryRestoreFile -Path TestDrive:\foo\bar\does\not\exist\ -EnableException } | Should Throw } diff --git a/tests/Grant-DbaAgPermission.Tests.p1.ps1 b/tests/Grant-DbaAgPermission.Tests.ps1 similarity index 59% rename from tests/Grant-DbaAgPermission.Tests.p1.ps1 rename to tests/Grant-DbaAgPermission.Tests.ps1 index d9ac7f012a..b0c1b57e23 100644 --- a/tests/Grant-DbaAgPermission.Tests.p1.ps1 +++ b/tests/Grant-DbaAgPermission.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Grant-DbaAgPermission).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'AvailabilityGroup', 'Type', 'Permission', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','AvailabilityGroup','Type','Permission','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Import-DbaCmsRegServer.Tests.ps1 b/tests/Import-DbaCmsRegServer.Tests.ps1 index 3646b218b9..8efad6304f 100644 --- a/tests/Import-DbaCmsRegServer.Tests.ps1 +++ b/tests/Import-DbaCmsRegServer.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'InputObject', 'Group', 'EnableException' - $SupportShouldProcess = $false - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','InputObject','Group','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Import-DbaCsv.Tests.ps1 b/tests/Import-DbaCsv.Tests.ps1 index e6467a5e36..80744b91ea 100644 --- a/tests/Import-DbaCsv.Tests.ps1 +++ b/tests/Import-DbaCsv.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Import-DbaCsv).Parameters.Keys - $knownParameters = 'Path', 'SqlInstance', 'SqlCredential', 'Database', 'Table', 'Schema', 'Truncate', 'Delimiter', 'SingleColumn', 'BatchSize', 'NotifyAfter', 'TableLock', 'CheckConstraints', 'FireTriggers', 'KeepIdentity', 'KeepNulls', 'Column', 'ColumnMap', 'AutoCreateTable', 'NoProgress', 'NoHeaderRow', 'Quote', 'Escape', 'Comment', 'TrimmingOption', 'BufferSize', 'ParseErrorAction', 'Encoding', 'NullValue', 'Threshold', 'MaxQuotedFieldLength', 'SkipEmptyLine', 'SupportsMultiline', 'UseColumnDefault', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','SqlInstance','SqlCredential','Database','Table','Schema','Truncate','Delimiter','SingleColumn','BatchSize','NotifyAfter','TableLock','CheckConstraints','FireTriggers','KeepIdentity','KeepNulls','Column','ColumnMap','AutoCreateTable','NoProgress','NoHeaderRow','Quote','Escape','Comment','TrimmingOption','BufferSize','ParseErrorAction','Encoding','NullValue','Threshold','MaxQuotedFieldLength','SkipEmptyLine','SupportsMultiline','UseColumnDefault','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Import-DbaPfDataCollectorSetTemplate.Tests.ps1 b/tests/Import-DbaPfDataCollectorSetTemplate.Tests.ps1 index 30c178cc4b..29136d60ea 100644 --- a/tests/Import-DbaPfDataCollectorSetTemplate.Tests.ps1 +++ b/tests/Import-DbaPfDataCollectorSetTemplate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 20 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Import-DbaPfDataCollectorSetTemplate).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'DisplayName', 'SchedulesEnabled', 'RootPath', 'Segment', 'SegmentMaxDuration', 'SegmentMaxSize', 'Subdirectory', 'SubdirectoryFormat', 'SubdirectoryFormatPattern', 'Task', 'TaskRunAsSelf', 'TaskArguments', 'TaskUserTextArguments', 'StopOnCompletion', 'Path', 'Template', 'Instance', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','DisplayName','SchedulesEnabled','RootPath','Segment','SegmentMaxDuration','SegmentMaxSize','Subdirectory','SubdirectoryFormat','SubdirectoryFormatPattern','Task','TaskRunAsSelf','TaskArguments','TaskUserTextArguments','StopOnCompletion','Path','Template','Instance','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Import-DbaSpConfigure.Tests.ps1 b/tests/Import-DbaSpConfigure.Tests.ps1 index b8605d57b9..c2003d99ed 100644 --- a/tests/Import-DbaSpConfigure.Tests.ps1 +++ b/tests/Import-DbaSpConfigure.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Import-DbaSpConfigure).Parameters.Keys - $knownParameters = 'Source', 'Destination', 'SourceSqlCredential', 'DestinationSqlCredential', 'SqlInstance', 'Path', 'SqlCredential', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','Destination','SourceSqlCredential','DestinationSqlCredential','SqlInstance','Path','SqlCredential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Import-DbaXESessionTemplate.Tests.ps1 b/tests/Import-DbaXESessionTemplate.Tests.ps1 index 1dedcb4757..21a23a8e91 100644 --- a/tests/Import-DbaXESessionTemplate.Tests.ps1 +++ b/tests/Import-DbaXESessionTemplate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Import-DbaXESessionTemplate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'Path', 'Template', 'TargetFilePath', 'TargetFileMetadataPath', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','Path','Template','TargetFilePath','TargetFileMetadataPath','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Install-DbaFirstResponderKit.Tests.ps1 b/tests/Install-DbaFirstResponderKit.Tests.ps1 index fcbb7bebe9..424c0d5ed2 100644 --- a/tests/Install-DbaFirstResponderKit.Tests.ps1 +++ b/tests/Install-DbaFirstResponderKit.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $commonParamCount = ([System.Management.Automation.PSCmdlet]::CommonParameters).Count + 2 - [object[]]$params = (Get-ChildItem function:\Install-DbaFirstResponderKit).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Branch', 'Database', 'Force', 'LocalFile', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $commonParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Branch','Database','LocalFile','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Install-DbaMaintenanceSolution.Tests.ps1 b/tests/Install-DbaMaintenanceSolution.Tests.ps1 index fd0bc0dbbb..5004cf02e0 100644 --- a/tests/Install-DbaMaintenanceSolution.Tests.ps1 +++ b/tests/Install-DbaMaintenanceSolution.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 13 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Install-DbaMaintenanceSolution).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'BackupLocation', 'CleanupTime', 'OutputFileDirectory', 'ReplaceExisting', 'LogToTable', 'Solution', 'InstallJobs', 'LocalFile', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','BackupLocation','CleanupTime','OutputFileDirectory','ReplaceExisting','LogToTable','Solution','InstallJobs','LocalFile','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Install-DbaSqlWatch.Tests.ps1 b/tests/Install-DbaSqlWatch.Tests.ps1 index 9012cb08eb..f46e80fc21 100644 --- a/tests/Install-DbaSqlWatch.Tests.ps1 +++ b/tests/Install-DbaSqlWatch.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $commonParamCount = ([System.Management.Automation.PSCmdlet]::CommonParameters).Count + 2 - [object[]]$params = (Get-ChildItem function:\Install-DbaSqlWatch).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Force', 'LocalFile', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $commonParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','LocalFile','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Install-DbaWatchUpdate.Tests.ps1 b/tests/Install-DbaWatchUpdate.Tests.ps1 index 41bceee52a..9772fe3a3b 100644 --- a/tests/Install-DbaWatchUpdate.Tests.ps1 +++ b/tests/Install-DbaWatchUpdate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Install-DbaWatchUpdate).Parameters.Keys - $knownParameters = 'TaskName', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'TaskName','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Install-DbaWhoIsActive.Tests.ps1 b/tests/Install-DbaWhoIsActive.Tests.ps1 index 2b14c3bccf..a00ab9c773 100644 --- a/tests/Install-DbaWhoIsActive.Tests.ps1 +++ b/tests/Install-DbaWhoIsActive.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Install-DbaWhoIsActive).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'LocalFile', 'Database', 'EnableException', 'Force' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','LocalFile','Database','EnableException','Force' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaAdvancedRestore.Tests.ps1 b/tests/Invoke-DbaAdvancedRestore.Tests.ps1 index 324cb38500..7d6e2c2fbc 100644 --- a/tests/Invoke-DbaAdvancedRestore.Tests.ps1 +++ b/tests/Invoke-DbaAdvancedRestore.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 17 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaAdvancedRestore).Parameters.Keys - $knownParameters = 'BackupHistory', 'SqlInstance', 'SqlCredential', 'OutputScriptOnly', 'VerifyOnly', 'RestoreTime', 'StandbyDirectory', 'NoRecovery', 'MaxTransferSize', 'BlockSize', 'BufferCount', 'Continue', 'AzureCredential', 'WithReplace', 'KeepCDC', 'PageRestore', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'BackupHistory','SqlInstance','SqlCredential','OutputScriptOnly','VerifyOnly','RestoreTime','StandbyDirectory','NoRecovery','MaxTransferSize','BlockSize','BufferCount','Continue','AzureCredential','WithReplace','KeepCDC','PageRestore','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaBalanceDataFiles.Tests.ps1 b/tests/Invoke-DbaBalanceDataFiles.Tests.ps1 index 94874a2d86..814326a184 100644 --- a/tests/Invoke-DbaBalanceDataFiles.Tests.ps1 +++ b/tests/Invoke-DbaBalanceDataFiles.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaBalanceDataFiles).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Table', 'RebuildOffline', 'EnableException', 'Force' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Table','RebuildOffline','EnableException','Force' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaCycleErrorLog.Tests.ps1 b/tests/Invoke-DbaCycleErrorLog.Tests.ps1 index c682809742..016c3662ae 100644 --- a/tests/Invoke-DbaCycleErrorLog.Tests.ps1 +++ b/tests/Invoke-DbaCycleErrorLog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaCycleErrorLog).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Type', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Type','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbClone.Tests.ps1 b/tests/Invoke-DbaDbClone.Tests.ps1 index e46a788c13..17a9cc429a 100644 --- a/tests/Invoke-DbaDbClone.Tests.ps1 +++ b/tests/Invoke-DbaDbClone.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'CloneDatabase', 'ExcludeStatistics', 'ExcludeQueryStore', 'UpdateStatistics', 'EnableException', 'InputObject' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','CloneDatabase','ExcludeStatistics','ExcludeQueryStore','UpdateStatistics','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbCorruption.Tests.ps1 b/tests/Invoke-DbaDbCorruption.Tests.ps1 index 8e4f7d64b8..530f62bdc0 100644 --- a/tests/Invoke-DbaDbCorruption.Tests.ps1 +++ b/tests/Invoke-DbaDbCorruption.Tests.ps1 @@ -1,22 +1,23 @@ $CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" +. "$PSScriptRoot\..\internal\functions\Invoke-DbaDbCorruption.ps1" Describe "$commandname Unit Tests" -Tags "UnitTests" { - Context "Validating Database Input" { - Invoke-DbaDbCorruption -SqlInstance $script:instance2 -Database "master" -WarningAction SilentlyContinue -WarningVariable systemwarn - It "Should not allow you to corrupt system databases." { - $systemwarn -match 'may not corrupt system databases' | Should Be $true - } - It "Should fail if more than one database is specified" { - { Invoke-DbaDbCorruption -SqlInstance $script:instance2 -Database "Database1", "Database2" -EnableException } | Should Throw + + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Table','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } - - Context "It's Confirm impact should be high" { - $command = Get-Command Invoke-DbaDbCorruption - $metadata = [System.Management.Automation.CommandMetadata]$command - $metadata.ConfirmImpact | Should Be 'High' + Context "Validate Confirm impact" { + It "Confirm Impact should be high" { + $metadata = [System.Management.Automation.CommandMetadata](Get-Command $CommandName) + $metadata.ConfirmImpact | Should Be 'High' + } } } @@ -27,21 +28,31 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { $TableName = "Example" # Need a clean empty database $null = $Server.Query("Create Database [$dbname]") - $db = Get-DbaDatabase -SqlInstance $Server -Database $dbname + $db = Get-DbaDatabase -SqlInstance $script:instance2 -Database $dbname } AfterAll { # Cleanup - Remove-DbaDatabase -SqlInstance $Server -Database $dbname -Confirm:$false + Remove-DbaDatabase -SqlInstance $script:instance2 -Database $dbname -Confirm:$false + } + + Context "Validating Database Input" { + Invoke-DbaDbCorruption -SqlInstance $script:instance2 -Database "master" -WarningAction SilentlyContinue -WarningVariable systemwarn + It "Should not allow you to corrupt system databases." { + $systemwarn -match 'may not corrupt system databases' | Should Be $true + } + It "Should fail if more than one database is specified" { + { Invoke-DbaDbCorruption -SqlInstance $script:instance2 -Database "Database1", "Database2" -EnableException } | Should Throw + } } It "Require at least a single table in the database specified" { - { Invoke-DbaDbCorruption -SqlInstance $server -Database $dbname -EnableException } | Should Throw + { Invoke-DbaDbCorruption -SqlInstance $script:instance2 -Database $dbname -EnableException } | Should Throw } # Creating a table to make sure these are failing for different reasons It "Fail if the specified table does not exist" { - { Invoke-DbaDbCorruption -SqlInstance $server -Database $dbname -Table "DoesntExist$(New-Guid)" -EnableException } | Should Throw + { Invoke-DbaDbCorruption -SqlInstance $script:instance2 -Database $dbname -Table "DoesntExist$(New-Guid)" -EnableException } | Should Throw } $null = $db.Query(" @@ -55,7 +66,7 @@ Describe "$commandname Integration Tests" -Tags "IntegrationTests" { } It "Causes DBCC CHECKDB to fail" { - $result = Start-DbccCheck -Server $Server -dbname $dbname + $result = Start-DbccCheck -Server $server -dbname $dbname $result | Should Not Be 'Success' } } \ No newline at end of file diff --git a/tests/Invoke-DbaDbDataMasking.Tests.ps1 b/tests/Invoke-DbaDbDataMasking.Tests.ps1 index b118d2aa0a..3d4cc36361 100644 --- a/tests/Invoke-DbaDbDataMasking.Tests.ps1 +++ b/tests/Invoke-DbaDbDataMasking.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaDbDataMasking).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'FilePath', 'Locale', 'CharacterString', 'Table', 'Column', 'ExcludeTable', 'ExcludeColumn', 'Query', 'MaxValue', 'ModulusFactor', 'EnableException', 'ExactLength' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','FilePath','Locale','CharacterString','Table','Column','ExcludeTable','ExcludeColumn','Query','MaxValue','ModulusFactor','ExactLength','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbDbccCheckConstraint.Tests.ps1 b/tests/Invoke-DbaDbDbccCheckConstraint.Tests.ps1 index 66102a580e..a3d9c0413c 100644 --- a/tests/Invoke-DbaDbDbccCheckConstraint.Tests.ps1 +++ b/tests/Invoke-DbaDbDbccCheckConstraint.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Object', 'AllConstraints', 'AllErrorMessages', 'NoInformationalMessages', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Object','AllConstraints','AllErrorMessages','NoInformationalMessages','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbDbccCleanTable.Tests.ps1 b/tests/Invoke-DbaDbDbccCleanTable.Tests.ps1 index 7fda5b6341..bf0b7dfcf7 100644 --- a/tests/Invoke-DbaDbDbccCleanTable.Tests.ps1 +++ b/tests/Invoke-DbaDbDbccCleanTable.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Object', 'BatchSize', 'NoInformationalMessages', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Object','BatchSize','NoInformationalMessages','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbDbccUpdateUsage.Tests.ps1 b/tests/Invoke-DbaDbDbccUpdateUsage.Tests.ps1 index 2148d86d8f..8dfff3b7f9 100644 --- a/tests/Invoke-DbaDbDbccUpdateUsage.Tests.ps1 +++ b/tests/Invoke-DbaDbDbccUpdateUsage.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Table', 'Index', 'NoInformationalMessages', 'CountRows', 'EnableException' - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Table','Index','NoInformationalMessages','CountRows','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbDecryptObject.Tests.ps1 b/tests/Invoke-DbaDbDecryptObject.Tests.ps1 index fa5b74f611..53afa23e7c 100644 --- a/tests/Invoke-DbaDbDecryptObject.Tests.ps1 +++ b/tests/Invoke-DbaDbDecryptObject.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaDbDecryptObject).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ObjectName', 'EncodingType', 'ExportDestination', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ObjectName','EncodingType','ExportDestination','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbLogShipRecovery.Tests.ps1 b/tests/Invoke-DbaDbLogShipRecovery.Tests.ps1 index 2c7cfda77b..aa669cb743 100644 --- a/tests/Invoke-DbaDbLogShipRecovery.Tests.ps1 +++ b/tests/Invoke-DbaDbLogShipRecovery.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaDbLogShipRecovery).Parameters.Keys - $knownParameters = 'SqlInstance', 'Database', 'SqlCredential', 'NoRecovery', 'EnableException', 'Force', 'InputObject', 'Delay' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Database','SqlCredential','NoRecovery','EnableException','Force','InputObject','Delay' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbLogShipping.Tests.ps1 b/tests/Invoke-DbaDbLogShipping.Tests.ps1 index 8bb492ff20..b2ec672667 100644 --- a/tests/Invoke-DbaDbLogShipping.Tests.ps1 +++ b/tests/Invoke-DbaDbLogShipping.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SourceSqlInstance', 'DestinationSqlInstance', 'SourceSqlCredential', 'SourceCredential', 'DestinationSqlCredential', 'DestinationCredential', 'Database', 'BackupNetworkPath', 'BackupLocalPath', 'BackupJob', 'BackupRetention', 'BackupSchedule', 'BackupScheduleDisabled', 'BackupScheduleFrequencyType', 'BackupScheduleFrequencyInterval', 'BackupScheduleFrequencySubdayType', 'BackupScheduleFrequencySubdayInterval', 'BackupScheduleFrequencyRelativeInterval', 'BackupScheduleFrequencyRecurrenceFactor', 'BackupScheduleStartDate', 'BackupScheduleEndDate', 'BackupScheduleStartTime', 'BackupScheduleEndTime', 'BackupThreshold', 'CompressBackup', 'CopyDestinationFolder', 'CopyJob', 'CopyRetention', 'CopySchedule', 'CopyScheduleDisabled', 'CopyScheduleFrequencyType', 'CopyScheduleFrequencyInterval', 'CopyScheduleFrequencySubdayType', 'CopyScheduleFrequencySubdayInterval', 'CopyScheduleFrequencyRelativeInterval', 'CopyScheduleFrequencyRecurrenceFactor', 'CopyScheduleStartDate', 'CopyScheduleEndDate', 'CopyScheduleStartTime', 'CopyScheduleEndTime', 'DisconnectUsers', 'FullBackupPath', 'GenerateFullBackup', 'HistoryRetention', 'NoRecovery', 'NoInitialization', 'PrimaryMonitorServer', 'PrimaryMonitorCredential', 'PrimaryMonitorServerSecurityMode', 'PrimaryThresholdAlertEnabled', 'RestoreDataFolder', 'RestoreLogFolder', 'RestoreDelay', 'RestoreAlertThreshold', 'RestoreJob', 'RestoreRetention', 'RestoreSchedule', 'RestoreScheduleDisabled', 'RestoreScheduleFrequencyType', 'RestoreScheduleFrequencyInterval', 'RestoreScheduleFrequencySubdayType', 'RestoreScheduleFrequencySubdayInterval', 'RestoreScheduleFrequencyRelativeInterval', 'RestoreScheduleFrequencyRecurrenceFactor', 'RestoreScheduleStartDate', 'RestoreScheduleEndDate', 'RestoreScheduleStartTime', 'RestoreScheduleEndTime', 'RestoreThreshold', 'SecondaryDatabasePrefix', 'SecondaryDatabaseSuffix', 'SecondaryMonitorServer', 'SecondaryMonitorCredential', 'SecondaryMonitorServerSecurityMode', 'SecondaryThresholdAlertEnabled', 'Standby', 'StandbyDirectory', 'UseExistingFullBackup', 'UseBackupFolder', 'Force', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SourceSqlInstance','DestinationSqlInstance','SourceSqlCredential','SourceCredential','DestinationSqlCredential','DestinationCredential','Database','BackupNetworkPath','BackupLocalPath','BackupJob','BackupRetention','BackupSchedule','BackupScheduleDisabled','BackupScheduleFrequencyType','BackupScheduleFrequencyInterval','BackupScheduleFrequencySubdayType','BackupScheduleFrequencySubdayInterval','BackupScheduleFrequencyRelativeInterval','BackupScheduleFrequencyRecurrenceFactor','BackupScheduleStartDate','BackupScheduleEndDate','BackupScheduleStartTime','BackupScheduleEndTime','BackupThreshold','CompressBackup','CopyDestinationFolder','CopyJob','CopyRetention','CopySchedule','CopyScheduleDisabled','CopyScheduleFrequencyType','CopyScheduleFrequencyInterval','CopyScheduleFrequencySubdayType','CopyScheduleFrequencySubdayInterval','CopyScheduleFrequencyRelativeInterval','CopyScheduleFrequencyRecurrenceFactor','CopyScheduleStartDate','CopyScheduleEndDate','CopyScheduleStartTime','CopyScheduleEndTime','DisconnectUsers','FullBackupPath','GenerateFullBackup','HistoryRetention','NoRecovery','NoInitialization','PrimaryMonitorServer','PrimaryMonitorCredential','PrimaryMonitorServerSecurityMode','PrimaryThresholdAlertEnabled','RestoreDataFolder','RestoreLogFolder','RestoreDelay','RestoreAlertThreshold','RestoreJob','RestoreRetention','RestoreSchedule','RestoreScheduleDisabled','RestoreScheduleFrequencyType','RestoreScheduleFrequencyInterval','RestoreScheduleFrequencySubdayType','RestoreScheduleFrequencySubdayInterval','RestoreScheduleFrequencyRelativeInterval','RestoreScheduleFrequencyRecurrenceFactor','RestoreScheduleStartDate','RestoreScheduleEndDate','RestoreScheduleStartTime','RestoreScheduleEndTime','RestoreThreshold','SecondaryDatabasePrefix','SecondaryDatabaseSuffix','SecondaryMonitorServer','SecondaryMonitorCredential','SecondaryMonitorServerSecurityMode','SecondaryThresholdAlertEnabled','Standby','StandbyDirectory','UseExistingFullBackup','UseBackupFolder','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbMirrorFailover.Tests.ps1 b/tests/Invoke-DbaDbMirrorFailover.Tests.ps1 index 47d82e95b4..fa0381caf1 100644 --- a/tests/Invoke-DbaDbMirrorFailover.Tests.ps1 +++ b/tests/Invoke-DbaDbMirrorFailover.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaDbMirrorFailover).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbMirroring.Tests.ps1 b/tests/Invoke-DbaDbMirroring.Tests.ps1 index 9b9337adcd..a738e98f9e 100644 --- a/tests/Invoke-DbaDbMirroring.Tests.ps1 +++ b/tests/Invoke-DbaDbMirroring.Tests.ps1 @@ -2,6 +2,17 @@ $commandname = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" +Describe "$commandname Unit Tests" -Tag "UnitTests" { + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Primary','PrimarySqlCredential','Mirror','MirrorSqlCredential','Witness','WitnessSqlCredential','Database','SharedPath','InputObject','UseLastBackup','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} + Describe "$commandname Integration Tests" -Tag "IntegrationTests" { BeforeAll { $null = Get-DbaProcess -SqlInstance $script:instance2 | Where-Object Program -match dbatools | Stop-DbaProcess -Confirm:$false -WarningAction SilentlyContinue diff --git a/tests/Invoke-DbaDbShrink.Tests.ps1 b/tests/Invoke-DbaDbShrink.Tests.ps1 index a1f8ec3d36..5e77a0176b 100644 --- a/tests/Invoke-DbaDbShrink.Tests.ps1 +++ b/tests/Invoke-DbaDbShrink.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 14 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaDbShrink).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'AllUserDatabases', 'PercentFreeSpace', 'ShrinkMethod', 'StatementTimeout', 'LogsOnly', 'FileType', 'StepSize', 'ExcludeIndexStats', 'ExcludeUpdateUsage', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','AllUserDatabases','PercentFreeSpace','ShrinkMethod','FileType','StepSize','StatementTimeout','LogsOnly','ExcludeIndexStats','ExcludeUpdateUsage','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbUpgrade.Tests.ps1 b/tests/Invoke-DbaDbUpgrade.Tests.ps1 index d447650855..f4ed2b33a1 100644 --- a/tests/Invoke-DbaDbUpgrade.Tests.ps1 +++ b/tests/Invoke-DbaDbUpgrade.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 12 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaDbUpgrade).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'NoCheckDb', 'NoUpdateUsage', 'NoUpdateStats', 'NoRefreshView', 'AllUserDatabases', 'Force', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','NoCheckDb','NoUpdateUsage','NoUpdateStats','NoRefreshView','AllUserDatabases','Force','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbccDropCleanBuffer.Tests.ps1 b/tests/Invoke-DbaDbccDropCleanBuffer.Tests.ps1 index c5d842b70f..a974e4f1e5 100644 --- a/tests/Invoke-DbaDbccDropCleanBuffer.Tests.ps1 +++ b/tests/Invoke-DbaDbccDropCleanBuffer.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'NoInformationalMessages', 'EnableException' - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','NoInformationalMessages','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDbccFreeCache.Tests.ps1 b/tests/Invoke-DbaDbccFreeCache.Tests.ps1 index 3f9c96505a..495f5e6176 100644 --- a/tests/Invoke-DbaDbccFreeCache.Tests.ps1 +++ b/tests/Invoke-DbaDbccFreeCache.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-Command -Name $CommandName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Operation', 'InputValue', 'NoInformationalMessages', 'MarkInUseForRemoval', 'EnableException' - - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Operation','InputValue','NoInformationalMessages','MarkInUseForRemoval','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaDiagnosticQuery.Tests.ps1 b/tests/Invoke-DbaDiagnosticQuery.Tests.ps1 index f13b062f94..9bdcb0c0c2 100644 --- a/tests/Invoke-DbaDiagnosticQuery.Tests.ps1 +++ b/tests/Invoke-DbaDiagnosticQuery.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 16 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaDiagnosticQuery).Parameters.Keys - $knownParameters = 'SqlInstance', 'Database', 'ExcludeDatabase', 'ExcludeQuery', 'SqlCredential', 'Path', 'QueryName', 'UseSelectionHelper', 'InstanceOnly', 'DatabaseSpecific', 'ExcludeQueryTextColumn', 'ExcludePlanColumn', 'NoColumnParsing', 'OutputPath', 'ExportQueries', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Database','ExcludeDatabase','ExcludeQuery','SqlCredential','Path','QueryName','UseSelectionHelper','InstanceOnly','DatabaseSpecific','ExcludeQueryTextColumn','ExcludePlanColumn','NoColumnParsing','OutputPath','ExportQueries','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaPfRelog.Tests.ps1 b/tests/Invoke-DbaPfRelog.Tests.ps1 index 188d4fb939..5ef0c0ff80 100644 --- a/tests/Invoke-DbaPfRelog.Tests.ps1 +++ b/tests/Invoke-DbaPfRelog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 17 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaPfRelog).Parameters.Keys - $knownParameters = 'Path', 'Destination', 'Type', 'Append', 'AllowClobber', 'PerformanceCounter', 'PerformanceCounterPath', 'Interval', 'BeginTime', 'EndTime', 'ConfigPath', 'Summary', 'InputObject', 'Multithread', 'AllTime', 'Raw', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','Destination','Type','Append','AllowClobber','PerformanceCounter','PerformanceCounterPath','Interval','BeginTime','EndTime','ConfigPath','Summary','InputObject','Multithread','AllTime','Raw','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaQuery.Tests.ps1 b/tests/Invoke-DbaQuery.Tests.ps1 index 40ec9047f1..2afc79b15a 100644 --- a/tests/Invoke-DbaQuery.Tests.ps1 +++ b/tests/Invoke-DbaQuery.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Invoke-DbaQuery).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Query', 'QueryTimeout', 'File', 'SqlObject', 'As', 'SqlParameters', 'AppendServerInstance', 'MessagesToOutput', 'InputObject', 'EnableException', 'ReadOnly' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Query','QueryTimeout','File','SqlObject','As','SqlParameters','AppendServerInstance','MessagesToOutput','InputObject','ReadOnly','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaWhoisActive.Tests.ps1 b/tests/Invoke-DbaWhoisActive.Tests.ps1 index 1866bde34f..2ca40ee951 100644 --- a/tests/Invoke-DbaWhoisActive.Tests.ps1 +++ b/tests/Invoke-DbaWhoisActive.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 28 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaWhoisActive).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Filter', 'FilterType', 'NotFilter', 'NotFilterType', 'ShowOwnSpid', 'ShowSystemSpids', 'ShowSleepingSpids', 'GetFullInnerText', 'GetPlans', 'GetOuterCommand', 'GetTransactionInfo', 'GetTaskInfo', 'GetLocks', 'GetAverageTime', 'GetAdditonalInfo', 'FindBlockLeaders', 'DeltaInterval', 'OutputColumnList', 'SortOrder', 'FormatOutput', 'DestinationTable', 'ReturnSchema', 'Schema', 'Help', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Filter','FilterType','NotFilter','NotFilterType','ShowOwnSpid','ShowSystemSpids','ShowSleepingSpids','GetFullInnerText','GetPlans','GetOuterCommand','GetTransactionInfo','GetTaskInfo','GetLocks','GetAverageTime','GetAdditonalInfo','FindBlockLeaders','DeltaInterval','OutputColumnList','SortOrder','FormatOutput','DestinationTable','ReturnSchema','Schema','Help','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbaXEReplay.Tests.ps1 b/tests/Invoke-DbaXEReplay.Tests.ps1 index 8edd36bec2..f7b8f573dc 100644 --- a/tests/Invoke-DbaXEReplay.Tests.ps1 +++ b/tests/Invoke-DbaXEReplay.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Invoke-DbaXEReplay).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Event', 'InputObject', 'Raw', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Event','InputObject','Raw','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbatoolsFormatter.Tests.ps1 b/tests/Invoke-DbatoolsFormatter.Tests.ps1 index b5a9a7c448..516ca434d2 100644 --- a/tests/Invoke-DbatoolsFormatter.Tests.ps1 +++ b/tests/Invoke-DbatoolsFormatter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Invoke-DbatoolsFormatter).Parameters.Keys - $knownParameters = 'Path','EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should -Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Invoke-DbatoolsRenameHelper.Tests.ps1 b/tests/Invoke-DbatoolsRenameHelper.Tests.ps1 index d980655aae..4b7cd4ae04 100644 --- a/tests/Invoke-DbatoolsRenameHelper.Tests.ps1 +++ b/tests/Invoke-DbatoolsRenameHelper.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Invoke-DbatoolsRenameHelper).Parameters.Keys - $knownParameters = 'InputObject', 'Encoding', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','Encoding','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Measure-DbaBackupThroughput.Tests.ps1 b/tests/Measure-DbaBackupThroughput.Tests.ps1 index 0008945a97..c5d28ed539 100644 --- a/tests/Measure-DbaBackupThroughput.Tests.ps1 +++ b/tests/Measure-DbaBackupThroughput.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Measure-DbaBackupThroughput).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Since', 'Last', 'Type', 'DeviceType', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Since','Last','Type','DeviceType','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Measure-DbaDiskSpaceRequirement.Tests.ps1 b/tests/Measure-DbaDiskSpaceRequirement.Tests.ps1 index 99b5e30706..9ff7b78d30 100644 --- a/tests/Measure-DbaDiskSpaceRequirement.Tests.ps1 +++ b/tests/Measure-DbaDiskSpaceRequirement.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Measure-DbaDiskSpaceRequirement).Parameters.Keys - $knownParameters = 'Source', 'Database', 'SourceSqlCredential', 'Destination', 'DestinationDatabase', 'DestinationSqlCredential', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','Database','SourceSqlCredential','Destination','DestinationDatabase','DestinationSqlCredential','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Measure-DbatoolsImport.Tests.ps1 b/tests/Measure-DbatoolsImport.Tests.ps1 index c4d8993bdf..294adae443 100644 --- a/tests/Measure-DbatoolsImport.Tests.ps1 +++ b/tests/Measure-DbatoolsImport.Tests.ps1 @@ -4,18 +4,15 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 0 - $defaultParamCount = 0 - [object[]]$params = (Get-ChildItem function:\Measure-DbatoolsImport).Parameters.Keys - $knownParameters = '' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = $null + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It -Skip "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } + <# Integration test should appear below and are custom to the command you are writing. Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests diff --git a/tests/Mount-DbaDatabase.Tests.ps1 b/tests/Mount-DbaDatabase.Tests.ps1 index f77d520368..3cf0e99986 100644 --- a/tests/Mount-DbaDatabase.Tests.ps1 +++ b/tests/Mount-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Mount-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'FileStructure', 'DatabaseOwner', 'AttachOption', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','FileStructure','DatabaseOwner','AttachOption','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Move-DbaCmsRegServer.Tests.ps1 b/tests/Move-DbaCmsRegServer.Tests.ps1 index fc5a6554c8..32edae6571 100644 --- a/tests/Move-DbaCmsRegServer.Tests.ps1 +++ b/tests/Move-DbaCmsRegServer.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'ServerName', 'NewGroup', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','ServerName','NewGroup','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Move-DbaCmsRegServerGroup.Tests.ps1 b/tests/Move-DbaCmsRegServerGroup.Tests.ps1 index 6821756411..5bcd0fb003 100644 --- a/tests/Move-DbaCmsRegServerGroup.Tests.ps1 +++ b/tests/Move-DbaCmsRegServerGroup.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Group', 'NewGroup', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Group','NewGroup','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaAgentJob.Tests.ps1 b/tests/New-DbaAgentJob.Tests.ps1 index 37a658b1ae..fe5418f14b 100644 --- a/tests/New-DbaAgentJob.Tests.ps1 +++ b/tests/New-DbaAgentJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 19 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaAgentJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'Schedule', 'ScheduleId', 'Disabled', 'Description', 'StartStepId', 'Category', 'OwnerLogin', 'EventLogLevel', 'EmailLevel', 'PageLevel', 'EmailOperator', 'NetsendOperator', 'PageOperator', 'DeleteLevel', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','Schedule','ScheduleId','Disabled','Description','StartStepId','Category','OwnerLogin','EventLogLevel','EmailLevel','PageLevel','EmailOperator','NetsendOperator','PageOperator','DeleteLevel','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaAgentJobCategory.Tests.ps1 b/tests/New-DbaAgentJobCategory.Tests.ps1 index 681312c1a1..07716b3916 100644 --- a/tests/New-DbaAgentJobCategory.Tests.ps1 +++ b/tests/New-DbaAgentJobCategory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaAgentJobCategory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Category', 'CategoryType', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Category','CategoryType','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaAgentJobStep.Tests.ps1 b/tests/New-DbaAgentJobStep.Tests.ps1 index 6a78e3393e..b0327059ce 100644 --- a/tests/New-DbaAgentJobStep.Tests.ps1 +++ b/tests/New-DbaAgentJobStep.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 22 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaAgentJobStep).Parameters.Keys - $knownParameters = 'SubSystemServer','SqlInstance', 'SqlCredential', 'Job', 'StepId', 'StepName', 'Subsystem', 'Command', 'CmdExecSuccessCode', 'OnSuccessAction', 'OnSuccessStepId', 'OnFailAction', 'OnFailStepId', 'Database', 'DatabaseUser', 'RetryAttempts', 'RetryInterval', 'OutputFileName', 'Flag', 'ProxyName', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','StepId','StepName','Subsystem','SubsystemServer','Command','CmdExecSuccessCode','OnSuccessAction','OnSuccessStepId','OnFailAction','OnFailStepId','Database','DatabaseUser','RetryAttempts','RetryInterval','OutputFileName','Flag','ProxyName','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaAgentProxy.Tests.ps1 b/tests/New-DbaAgentProxy.Tests.ps1 index a1bc65ab56..f97bedc618 100644 --- a/tests/New-DbaAgentProxy.Tests.ps1 +++ b/tests/New-DbaAgentProxy.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 12 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaAgentProxy).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'ProxyCredential', 'SubSystem', 'Description', 'Login', 'ServerRole', 'MsdbRole', 'Disabled', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','ProxyCredential','SubSystem','Description','Login','ServerRole','MsdbRole','Disabled','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaAgentSchedule.Tests.ps1 b/tests/New-DbaAgentSchedule.Tests.ps1 index d950d3faa3..c4c6e19498 100644 --- a/tests/New-DbaAgentSchedule.Tests.ps1 +++ b/tests/New-DbaAgentSchedule.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 17 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaAgentSchedule).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'Schedule', 'Disabled', 'FrequencyType', 'FrequencyInterval', 'FrequencySubdayType', 'FrequencySubdayInterval', 'FrequencyRelativeInterval', 'FrequencyRecurrenceFactor', 'StartDate', 'EndDate', 'StartTime', 'EndTime', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','Schedule','Disabled','FrequencyType','FrequencyInterval','FrequencySubdayType','FrequencySubdayInterval','FrequencyRelativeInterval','FrequencyRecurrenceFactor','StartDate','EndDate','StartTime','EndTime','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaAvailabilityGroup.Tests.ps1 b/tests/New-DbaAvailabilityGroup.Tests.ps1 index f53b9a0ee1..5f934f270a 100644 --- a/tests/New-DbaAvailabilityGroup.Tests.ps1 +++ b/tests/New-DbaAvailabilityGroup.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 31 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaAvailabilityGroup).Parameters.Keys - $knownParameters = 'Primary', 'PrimarySqlCredential', 'Secondary', 'SecondarySqlCredential', 'Name', 'DtcSupport', 'ClusterType', 'AutomatedBackupPreference', 'FailureConditionLevel', 'HealthCheckTimeout', 'Basic', 'DatabaseHealthTrigger', 'Passthru', 'Database', 'SharedPath', 'UseLastBackup', 'Force', 'AvailabilityMode', 'FailoverMode', 'BackupPriority', 'ConnectionModeInPrimaryRole', 'ConnectionModeInSecondaryRole', 'SeedingMode', 'Endpoint', 'ReadonlyRoutingConnectionUrl', 'Certificate', 'IPAddress', 'SubnetMask', 'Port', 'Dhcp', 'EnableException' - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Primary','PrimarySqlCredential','Secondary','SecondarySqlCredential','Name','DtcSupport','ClusterType','AutomatedBackupPreference','FailureConditionLevel','HealthCheckTimeout','Basic','DatabaseHealthTrigger','Passthru','Database','SharedPath','UseLastBackup','Force','AvailabilityMode','FailoverMode','BackupPriority','ConnectionModeInPrimaryRole','ConnectionModeInSecondaryRole','SeedingMode','Endpoint','ReadonlyRoutingConnectionUrl','Certificate','IPAddress','SubnetMask','Port','Dhcp','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaClientAlias.Tests.ps1 b/tests/New-DbaClientAlias.Tests.ps1 index 7fdb7763a4..96c46e9d14 100644 --- a/tests/New-DbaClientAlias.Tests.ps1 +++ b/tests/New-DbaClientAlias.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaClientAlias).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'ServerName', 'Alias', 'Protocol', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','ServerName','Alias','Protocol','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaCmConnection.Tests.ps1 b/tests/New-DbaCmConnection.Tests.ps1 index 1bbe8d5eae..500af1be1f 100644 --- a/tests/New-DbaCmConnection.Tests.ps1 +++ b/tests/New-DbaCmConnection.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 13 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaCmConnection).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'UseWindowsCredentials', 'OverrideExplicitCredential', 'DisabledConnectionTypes', 'DisableBadCredentialCache', 'DisableCimPersistence', 'DisableCredentialAutoRegister', 'EnableCredentialFailover', 'WindowsCredentialsAreBad', 'CimWinRMOptions', 'CimDCOMOptions', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','UseWindowsCredentials','OverrideExplicitCredential','DisabledConnectionTypes','DisableBadCredentialCache','DisableCimPersistence','DisableCredentialAutoRegister','EnableCredentialFailover','WindowsCredentialsAreBad','CimWinRMOptions','CimDCOMOptions','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaComputerCertificate.Tests.ps1 b/tests/New-DbaComputerCertificate.Tests.ps1 index 505b786d54..c94c1e7c56 100644 --- a/tests/New-DbaComputerCertificate.Tests.ps1 +++ b/tests/New-DbaComputerCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 14 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaComputerCertificate).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CaServer', 'CaName', 'ClusterInstanceName', 'SecurePassword', 'FriendlyName', 'CertificateTemplate', 'KeyLength', 'Store', 'Folder', 'Dns', 'SelfSigned', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CaServer','CaName','ClusterInstanceName','SecurePassword','FriendlyName','CertificateTemplate','KeyLength','Store','Folder','Dns','SelfSigned','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaConnectionString.Tests.ps1 b/tests/New-DbaConnectionString.Tests.ps1 index 8580b38af5..a751839c5a 100644 --- a/tests/New-DbaConnectionString.Tests.ps1 +++ b/tests/New-DbaConnectionString.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 24 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaConnectionString).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'AccessToken', 'ApplicationIntent', 'BatchSeparator', 'ClientName', 'ConnectTimeout', 'EncryptConnection', 'FailoverPartner', 'IsActiveDirectoryUniversalAuth', 'LockTimeout', 'MaxPoolSize', 'MinPoolSize', 'MultipleActiveResultSets', 'MultiSubnetFailover', 'NetworkProtocol', 'NonPooledConnection', 'PacketSize', 'PooledConnectionLifetime', 'SqlExecutionModes', 'StatementTimeout', 'TrustServerCertificate', 'WorkstationId', 'AppendConnectionString' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','AccessToken','ApplicationIntent','BatchSeparator','ClientName','ConnectTimeout','EncryptConnection','FailoverPartner','IsActiveDirectoryUniversalAuth','LockTimeout','MaxPoolSize','MinPoolSize','MultipleActiveResultSets','MultiSubnetFailover','NetworkProtocol','NonPooledConnection','PacketSize','PooledConnectionLifetime','SqlExecutionModes','StatementTimeout','TrustServerCertificate','WorkstationId','AppendConnectionString' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaConnectionStringBuilder.Tests.ps1 b/tests/New-DbaConnectionStringBuilder.Tests.ps1 index 1e9117ca74..95be5d3714 100644 --- a/tests/New-DbaConnectionStringBuilder.Tests.ps1 +++ b/tests/New-DbaConnectionStringBuilder.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaConnectionStringBuilder).Parameters.Keys - $knownParameters = 'ConnectionString', 'ApplicationName', 'DataSource', 'InitialCatalog', 'IntegratedSecurity', 'UserName', 'Password', 'MultipleActiveResultSets', 'ColumnEncryptionSetting', 'WorkstationId' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ConnectionString','ApplicationName','DataSource','InitialCatalog','IntegratedSecurity','UserName','Password','MultipleActiveResultSets','ColumnEncryptionSetting','WorkstationId' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaCredential.Tests.ps1 b/tests/New-DbaCredential.Tests.ps1 index f904ea4143..fcd829e8d0 100644 --- a/tests/New-DbaCredential.Tests.ps1 +++ b/tests/New-DbaCredential.Tests.ps1 @@ -5,15 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaCredential).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'Identity', 'SecurePassword', 'MappedClassType', 'ProviderName', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','Identity','SecurePassword','MappedClassType','ProviderName','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDacOption.Tests.ps1 b/tests/New-DbaDacOption.Tests.ps1 index be283f41b3..3fb8b44a4a 100644 --- a/tests/New-DbaDacOption.Tests.ps1 +++ b/tests/New-DbaDacOption.Tests.ps1 @@ -3,6 +3,16 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" Describe "$commandname Unit Tests" -Tag "UnitTests" { + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Type','Action','PublishXml','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} +Describe "$commandname Integration Tests" -Tag "IntegrationTests" { BeforeAll { $publishprofile = New-DbaDacProfile -SqlInstance $script:instance1 -Database whatever -Path C:\temp } diff --git a/tests/New-DbaDacProfile.Tests.ps1 b/tests/New-DbaDacProfile.Tests.ps1 index 80f1211ab1..30a3f03428 100644 --- a/tests/New-DbaDacProfile.Tests.ps1 +++ b/tests/New-DbaDacProfile.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDacProfile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Path', 'ConnectionString', 'PublishOptions', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Path','ConnectionString','PublishOptions','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDatabase.Tests.ps1 b/tests/New-DbaDatabase.Tests.ps1 index f011ce9fd5..2fe3f760c5 100644 --- a/tests/New-DbaDatabase.Tests.ps1 +++ b/tests/New-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'Collation', 'Recoverymodel', 'Owner', 'DataFilePath', 'LogFilePath', 'PrimaryFilesize', 'PrimaryFileGrowth', 'PrimaryFileMaxSize', 'LogSize', 'LogGrowth', 'SecondaryFilesize', 'SecondaryFileGrowth', 'SecondaryFileMaxSize', 'SecondaryFileCount', 'DefaultFileGroup', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','Collation','Recoverymodel','Owner','DataFilePath','LogFilePath','PrimaryFilesize','PrimaryFileGrowth','PrimaryFileMaxSize','LogSize','LogGrowth','SecondaryFilesize','SecondaryFileGrowth','SecondaryFileMaxSize','SecondaryFileCount','DefaultFileGroup','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDbCertificate.Tests.ps1 b/tests/New-DbaDbCertificate.Tests.ps1 index 3114b83c37..0a72ec3dee 100644 --- a/tests/New-DbaDbCertificate.Tests.ps1 +++ b/tests/New-DbaDbCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 11 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDbCertificate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'Database', 'Subject', 'StartDate', 'ExpirationDate', 'ActiveForServiceBrokerDialog', 'SecurePassword', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','Database','Subject','StartDate','ExpirationDate','ActiveForServiceBrokerDialog','SecurePassword','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDbMaskingConfig.Tests.ps1 b/tests/New-DbaDbMaskingConfig.Tests.ps1 index 9465837788..123343685f 100644 --- a/tests/New-DbaDbMaskingConfig.Tests.ps1 +++ b/tests/New-DbaDbMaskingConfig.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDbMaskingConfig).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Table', 'Column', 'Path', 'Locale', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Table','Column','Path','Locale','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDbMasterKey.Tests.ps1 b/tests/New-DbaDbMasterKey.Tests.ps1 index 61b777d6ae..e01c0331e9 100644 --- a/tests/New-DbaDbMasterKey.Tests.ps1 +++ b/tests/New-DbaDbMasterKey.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDbMasterKey).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Credential', 'SecurePassword', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','Database','SecurePassword','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDbSnapshot.Tests.ps1 b/tests/New-DbaDbSnapshot.Tests.ps1 index dd3e02497a..150495c410 100644 --- a/tests/New-DbaDbSnapshot.Tests.ps1 +++ b/tests/New-DbaDbSnapshot.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 11 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDbSnapshot).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'AllDatabases', 'Name', 'NameSuffix', 'Path', 'Force', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','AllDatabases','Name','NameSuffix','Path','Force','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDbUser.Tests.ps1 b/tests/New-DbaDbUser.Tests.ps1 index 6a1cf02348..13c905bba0 100644 --- a/tests/New-DbaDbUser.Tests.ps1 +++ b/tests/New-DbaDbUser.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDbUser).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IncludeSystem', 'Login', 'Username', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeSystem','Login','Username','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaDirectory.Tests.ps1 b/tests/New-DbaDirectory.Tests.ps1 index d2225f5f50..a66c58b145 100644 --- a/tests/New-DbaDirectory.Tests.ps1 +++ b/tests/New-DbaDirectory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaDirectory).Parameters.Keys - $knownParameters = 'SqlInstance', 'Path', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Path','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaEndpoint.Tests.ps1 b/tests/New-DbaEndpoint.Tests.ps1 index 35f4780ad0..ae2719ddec 100644 --- a/tests/New-DbaEndpoint.Tests.ps1 +++ b/tests/New-DbaEndpoint.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'Type', 'Protocol', 'Role', 'EndpointEncryption', 'EncryptionAlgorithm', 'Certificate', 'Port', 'SslPort', 'Owner', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','Type','Protocol','Role','EndpointEncryption','EncryptionAlgorithm','Certificate','Port','SslPort','Owner','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaLogin.Tests.ps1 b/tests/New-DbaLogin.Tests.ps1 index 220ceb183f..458827f714 100644 --- a/tests/New-DbaLogin.Tests.ps1 +++ b/tests/New-DbaLogin.Tests.ps1 @@ -7,15 +7,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 19 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'InputObject', 'LoginRenameHashtable', 'SecurePassword', 'HashedPassword', 'MapToCertificate', 'MapToAsymmetricKey', 'MapToCredential', 'Sid', 'DefaultDatabase', 'Language', 'PasswordExpiration', 'PasswordPolicy', 'Disabled', 'NewSid', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','InputObject','LoginRenameHashtable','SecurePassword','HashedPassword','MapToCertificate','MapToAsymmetricKey','MapToCredential','Sid','DefaultDatabase','Language','PasswordExpiration','PasswordPolicy','Disabled','NewSid','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaScriptingOption.Tests.ps1 b/tests/New-DbaScriptingOption.Tests.ps1 index ea82c5d41c..d3f33db929 100644 --- a/tests/New-DbaScriptingOption.Tests.ps1 +++ b/tests/New-DbaScriptingOption.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 0 - $defaultParamCount = 0 - [object[]]$params = (Get-ChildItem function:\New-DbaScriptingOption).Parameters.Keys - $knownParameters = '' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = $null + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It -Skip "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaServiceMasterKey.Tests.ps1 b/tests/New-DbaServiceMasterKey.Tests.ps1 index 984cfdc60d..678b064eaf 100644 --- a/tests/New-DbaServiceMasterKey.Tests.ps1 +++ b/tests/New-DbaServiceMasterKey.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaServiceMasterKey).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'SecurePassword', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','SecurePassword','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaSsisCatalog.Tests.ps1 b/tests/New-DbaSsisCatalog.Tests.ps1 index 1fe8a7b680..28bf77d58a 100644 --- a/tests/New-DbaSsisCatalog.Tests.ps1 +++ b/tests/New-DbaSsisCatalog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaSsisCatalog).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'SecurePassword', 'Credential', 'SsisCatalog', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','SecurePassword','SsisCatalog','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaXESession.Tests.ps1 b/tests/New-DbaXESession.Tests.ps1 index eb21bb5f9c..20a87e3705 100644 --- a/tests/New-DbaXESession.Tests.ps1 +++ b/tests/New-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaXESession).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaXESmartCsvWriter.Tests.ps1 b/tests/New-DbaXESmartCsvWriter.Tests.ps1 index e2f8985977..70b38cdfdf 100644 --- a/tests/New-DbaXESmartCsvWriter.Tests.ps1 +++ b/tests/New-DbaXESmartCsvWriter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaXESmartCsvWriter).Parameters.Keys - $knownParameters = 'OutputFile', 'Overwrite', 'Event', 'OutputColumn', 'Filter', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'OutputFile','Overwrite','Event','OutputColumn','Filter','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaXESmartEmail.Tests.ps1 b/tests/New-DbaXESmartEmail.Tests.ps1 index 4bd69bcdb8..5d0e5c0a87 100644 --- a/tests/New-DbaXESmartEmail.Tests.ps1 +++ b/tests/New-DbaXESmartEmail.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 14 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaXESmartEmail).Parameters.Keys - $knownParameters = 'SmtpServer', 'Sender', 'To', 'Cc', 'Bcc', 'Credential', 'Subject', 'Body', 'Attachment', 'AttachmentFileName', 'PlainText', 'Event', 'Filter', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SmtpServer','Sender','To','Cc','Bcc','Credential','Subject','Body','Attachment','AttachmentFileName','PlainText','Event','Filter','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaXESmartQueryExec.Tests.ps1 b/tests/New-DbaXESmartQueryExec.Tests.ps1 index 38718cc6c7..f160c3336d 100644 --- a/tests/New-DbaXESmartQueryExec.Tests.ps1 +++ b/tests/New-DbaXESmartQueryExec.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaXESmartQueryExec).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Query', 'EnableException', 'Event', 'Filter' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Query','EnableException','Event','Filter' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaXESmartReplay.Tests.ps1 b/tests/New-DbaXESmartReplay.Tests.ps1 index 2f76980d75..934cc67794 100644 --- a/tests/New-DbaXESmartReplay.Tests.ps1 +++ b/tests/New-DbaXESmartReplay.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaXESmartReplay).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Event', 'Filter', 'DelaySeconds', 'StopOnError', 'ReplayIntervalSeconds', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Event','Filter','DelaySeconds','StopOnError','ReplayIntervalSeconds','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbaXESmartTableWriter.Tests.ps1 b/tests/New-DbaXESmartTableWriter.Tests.ps1 index 1954fa50bc..ca0bd3dc44 100644 --- a/tests/New-DbaXESmartTableWriter.Tests.ps1 +++ b/tests/New-DbaXESmartTableWriter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbaXESmartTableWriter).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Table', 'AutoCreateTargetTable', 'UploadIntervalSeconds', 'Event', 'OutputColumn', 'Filter', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Table','AutoCreateTargetTable','UploadIntervalSeconds','Event','OutputColumn','Filter','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/New-DbatoolsSupportPackage.Tests.ps1 b/tests/New-DbatoolsSupportPackage.Tests.ps1 index 6e97a14305..456bfdf751 100644 --- a/tests/New-DbatoolsSupportPackage.Tests.ps1 +++ b/tests/New-DbatoolsSupportPackage.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\New-DbatoolsSupportPackage).Parameters.Keys - $knownParameters = 'Path', 'Variables', 'EnableException', 'PassThru' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','Variables','PassThru','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Publish-DbaDacPackage.Tests.ps1 b/tests/Publish-DbaDacPackage.Tests.ps1 index 50c040ce06..fa8f46eeb6 100644 --- a/tests/Publish-DbaDacPackage.Tests.ps1 +++ b/tests/Publish-DbaDacPackage.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Publish-DbaDacPackage).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'PublishXml', 'Database', 'ConnectionString', 'GenerateDeploymentScript', 'GenerateDeploymentReport', 'ScriptOnly', 'OutputPath', 'IncludeSqlCmdVars', 'EnableException', 'DacFxPath', 'Type', 'DacOption' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','PublishXml','Database','ConnectionString','GenerateDeploymentScript','GenerateDeploymentReport','ScriptOnly','Type','OutputPath','IncludeSqlCmdVars','DacOption','EnableException','DacFxPath' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Read-DbaAuditFile.Tests.ps1 b/tests/Read-DbaAuditFile.Tests.ps1 index b1287a19d2..b4aeed8a09 100644 --- a/tests/Read-DbaAuditFile.Tests.ps1 +++ b/tests/Read-DbaAuditFile.Tests.ps1 @@ -10,15 +10,11 @@ $base = (Get-Module -Name dbatools).ModuleBase Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Read-DbaAuditFile).Parameters.Keys - $knownParameters = 'Path', 'Exact', 'Raw', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','Exact','Raw','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Read-DbaBackupHeader.Tests.ps1 b/tests/Read-DbaBackupHeader.Tests.ps1 index aa4e291b3a..6524f72541 100644 --- a/tests/Read-DbaBackupHeader.Tests.ps1 +++ b/tests/Read-DbaBackupHeader.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Read-DbaBackupHeader).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'Simple', 'FileList', 'AzureCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','Simple','FileList','AzureCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Read-DbaTraceFile.Tests.ps1 b/tests/Read-DbaTraceFile.Tests.ps1 index 74451b552b..a230396b8d 100644 --- a/tests/Read-DbaTraceFile.Tests.ps1 +++ b/tests/Read-DbaTraceFile.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 15 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Read-DbaTraceFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'Database', 'Login', 'Spid', 'EventClass', 'ObjectType', 'ErrorId', 'EventSequence', 'TextData', 'ApplicationName', 'ObjectName', 'Where', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','Database','Login','Spid','EventClass','ObjectType','ErrorId','EventSequence','TextData','ApplicationName','ObjectName','Where','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Read-DbaTransactionLog.Tests.ps1 b/tests/Read-DbaTransactionLog.Tests.ps1 index 5dec9b12de..ff8c94f954 100644 --- a/tests/Read-DbaTransactionLog.Tests.ps1 +++ b/tests/Read-DbaTransactionLog.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Read-DbaTransactionLog).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'IgnoreLimit', 'EnableException', 'RowLimit' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','IgnoreLimit','RowLimit','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Read-DbaXEFile.Tests.ps1 b/tests/Read-DbaXEFile.Tests.ps1 index 3c44c42808..09691afb1d 100644 --- a/tests/Read-DbaXEFile.Tests.ps1 +++ b/tests/Read-DbaXEFile.Tests.ps1 @@ -10,15 +10,11 @@ $base = (Get-Module -Name dbatools).ModuleBase Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Read-DbaXEFile).Parameters.Keys - $knownParameters = 'Path', 'Exact', 'Raw', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','Exact','Raw','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Register-DbatoolsConfig.Tests.ps1 b/tests/Register-DbatoolsConfig.Tests.ps1 index 5157c35c81..d7b8c2ce16 100644 --- a/tests/Register-DbatoolsConfig.Tests.ps1 +++ b/tests/Register-DbatoolsConfig.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Register-DbatoolsConfig).Parameters.Keys - $knownParameters = 'Config', 'FullName', 'Module', 'Name', 'Scope', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Config','FullName','Module','Name','Scope','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAgDatabase.Tests.ps1 b/tests/Remove-DbaAgDatabase.Tests.ps1 index c6f5c463bf..08dab2952f 100644 --- a/tests/Remove-DbaAgDatabase.Tests.ps1 +++ b/tests/Remove-DbaAgDatabase.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAvailabilityGroup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'AllAvailabilityGroups', 'InputObject', 'EnableException' - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','AvailabilityGroup','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAgListener.Tests.ps1 b/tests/Remove-DbaAgListener.Tests.ps1 index 6bb9373127..b2a75e7d1f 100644 --- a/tests/Remove-DbaAgListener.Tests.ps1 +++ b/tests/Remove-DbaAgListener.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAgListener).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Listener', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Listener','AvailabilityGroup','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAgReplica.Tests.ps1 b/tests/Remove-DbaAgReplica.Tests.ps1 index a1ead80bbd..9eb510f672 100644 --- a/tests/Remove-DbaAgReplica.Tests.ps1 +++ b/tests/Remove-DbaAgReplica.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAgReplica).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Replica', 'InputObject', 'EnableException' - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Replica','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAgentJob.Tests.ps1 b/tests/Remove-DbaAgentJob.Tests.ps1 index eb48adc4a8..22bf23753a 100644 --- a/tests/Remove-DbaAgentJob.Tests.ps1 +++ b/tests/Remove-DbaAgentJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAgentJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'KeepHistory', 'KeepUnusedSchedule', 'Mode', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','KeepHistory','KeepUnusedSchedule','Mode','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAgentJobCategory.Tests.ps1 b/tests/Remove-DbaAgentJobCategory.Tests.ps1 index 23db2e0d69..6f7730b945 100644 --- a/tests/Remove-DbaAgentJobCategory.Tests.ps1 +++ b/tests/Remove-DbaAgentJobCategory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAgentJobCategory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Category', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Category','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAgentJobStep.Tests.ps1 b/tests/Remove-DbaAgentJobStep.Tests.ps1 index f9457ed2d8..c5ad4c687c 100644 --- a/tests/Remove-DbaAgentJobStep.Tests.ps1 +++ b/tests/Remove-DbaAgentJobStep.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAgentJobStep).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'StepName', 'Mode', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','StepName','Mode','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAgentSchedule.Tests.ps1 b/tests/Remove-DbaAgentSchedule.Tests.ps1 index a5412cd218..b624d2857a 100644 --- a/tests/Remove-DbaAgentSchedule.Tests.ps1 +++ b/tests/Remove-DbaAgentSchedule.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAgentSchedule).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Schedule', 'InputObject', 'EnableException', 'Force' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Schedule','InputObject','EnableException','Force' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaAvailabilityGroup.Tests.ps1 b/tests/Remove-DbaAvailabilityGroup.Tests.ps1 index 5f6459061a..b0e635d9f8 100644 --- a/tests/Remove-DbaAvailabilityGroup.Tests.ps1 +++ b/tests/Remove-DbaAvailabilityGroup.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaAvailabilityGroup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'AllAvailabilityGroups', 'InputObject', 'EnableException' - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','AllAvailabilityGroups','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaBackup.Tests.ps1 b/tests/Remove-DbaBackup.Tests.ps1 index 46ccc83fc6..bffd75ea26 100644 --- a/tests/Remove-DbaBackup.Tests.ps1 +++ b/tests/Remove-DbaBackup.Tests.ps1 @@ -5,11 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaBackup).Parameters.Keys - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','BackupFileExtension','RetentionPeriod','CheckArchiveBit','RemoveEmptyBackupFolder','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } Context "It's Confirm impact should be medium" { diff --git a/tests/Remove-DbaClientAlias.Tests.ps1 b/tests/Remove-DbaClientAlias.Tests.ps1 index a1d6dfb6ea..2196ecc690 100644 --- a/tests/Remove-DbaClientAlias.Tests.ps1 +++ b/tests/Remove-DbaClientAlias.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaClientAlias).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Alias', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Alias','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaCmConnection.Tests.ps1 b/tests/Remove-DbaCmConnection.Tests.ps1 index f41dc1fa45..d84401a383 100644 --- a/tests/Remove-DbaCmConnection.Tests.ps1 +++ b/tests/Remove-DbaCmConnection.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaCmConnection).Parameters.Keys - $knownParameters = 'ComputerName', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaCmsRegServer.Tests.ps1 b/tests/Remove-DbaCmsRegServer.Tests.ps1 index 9dd5357abb..e9f788ceb3 100644 --- a/tests/Remove-DbaCmsRegServer.Tests.ps1 +++ b/tests/Remove-DbaCmsRegServer.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'ServerName', 'Group', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','ServerName','Group','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaCmsRegServerGroup.Tests.ps1 b/tests/Remove-DbaCmsRegServerGroup.Tests.ps1 index 0955621e2d..5ff97e8c1f 100644 --- a/tests/Remove-DbaCmsRegServerGroup.Tests.ps1 +++ b/tests/Remove-DbaCmsRegServerGroup.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Name', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Name','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaComputerCertificate.Tests.ps1 b/tests/Remove-DbaComputerCertificate.Tests.ps1 index 3ff80f2ec6..f3eaebca2d 100644 --- a/tests/Remove-DbaComputerCertificate.Tests.ps1 +++ b/tests/Remove-DbaComputerCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaComputerCertificate).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Thumbprint', 'Store', 'Folder', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Thumbprint','Store','Folder','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDatabase.Tests.ps1 b/tests/Remove-DbaDatabase.Tests.ps1 index 1aa23196bd..7125f4a9ef 100644 --- a/tests/Remove-DbaDatabase.Tests.ps1 +++ b/tests/Remove-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'IncludeSystemDb', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','IncludeSystemDb','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDatabaseSafely.Tests.ps1 b/tests/Remove-DbaDatabaseSafely.Tests.ps1 index ea1e7a6117..535c0c12c0 100644 --- a/tests/Remove-DbaDatabaseSafely.Tests.ps1 +++ b/tests/Remove-DbaDatabaseSafely.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 14 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDatabaseSafely).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Destination', 'DestinationCredential', 'NoDbccCheckDb', 'BackupFolder', 'CategoryName', 'JobOwner', 'AllDatabases', 'BackupCompression', 'ReuseSourceFolderStructure', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Destination','DestinationCredential','NoDbccCheckDb','BackupFolder','CategoryName','JobOwner','AllDatabases','BackupCompression','ReuseSourceFolderStructure','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDbCertificate.Tests.ps1 b/tests/Remove-DbaDbCertificate.Tests.ps1 index 16aa076183..f88804f7e4 100644 --- a/tests/Remove-DbaDbCertificate.Tests.ps1 +++ b/tests/Remove-DbaDbCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDbCertificate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Certificate', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Certificate','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDbMasterKey.Tests.ps1 b/tests/Remove-DbaDbMasterKey.Tests.ps1 index 027f38237f..3066c868ec 100644 --- a/tests/Remove-DbaDbMasterKey.Tests.ps1 +++ b/tests/Remove-DbaDbMasterKey.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDbMasterKey).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'All', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','All','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDbMirror.Tests.ps1 b/tests/Remove-DbaDbMirror.Tests.ps1 index 47402d0a03..b7df21331c 100644 --- a/tests/Remove-DbaDbMirror.Tests.ps1 +++ b/tests/Remove-DbaDbMirror.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDbMirror).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDbMirrorMonitor.Tests.ps1 b/tests/Remove-DbaDbMirrorMonitor.Tests.ps1 index f350d3a3e6..4ed662e6bc 100644 --- a/tests/Remove-DbaDbMirrorMonitor.Tests.ps1 +++ b/tests/Remove-DbaDbMirrorMonitor.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDbOrphanUser.Tests.ps1 b/tests/Remove-DbaDbOrphanUser.Tests.ps1 index 6fa7dfbf66..5fe1565ece 100644 --- a/tests/Remove-DbaDbOrphanUser.Tests.ps1 +++ b/tests/Remove-DbaDbOrphanUser.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDbOrphanUser).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'User', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','User','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDbSnapshot.Tests.ps1 b/tests/Remove-DbaDbSnapshot.Tests.ps1 index 80a252b118..68e487d1e2 100644 --- a/tests/Remove-DbaDbSnapshot.Tests.ps1 +++ b/tests/Remove-DbaDbSnapshot.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDbSnapshot).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Snapshot', 'InputObject', 'AllSnapshots', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Snapshot','InputObject','AllSnapshots','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaDbUser.Tests.ps1 b/tests/Remove-DbaDbUser.Tests.ps1 index 6e3e1d2dfd..98a692fc79 100644 --- a/tests/Remove-DbaDbUser.Tests.ps1 +++ b/tests/Remove-DbaDbUser.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaDbUser).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'User', 'InputObject', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','User','InputObject','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaEndpoint.Tests.ps1 b/tests/Remove-DbaEndpoint.Tests.ps1 index 6c74aea4e9..46a413d474 100644 --- a/tests/Remove-DbaEndpoint.Tests.ps1 +++ b/tests/Remove-DbaEndpoint.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EndPoint', 'AllEndpoints', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EndPoint','AllEndpoints','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaLogin.Tests.ps1 b/tests/Remove-DbaLogin.Tests.ps1 index 6de704fa65..fe83410ca4 100644 --- a/tests/Remove-DbaLogin.Tests.ps1 +++ b/tests/Remove-DbaLogin.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'InputObject', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','InputObject','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaNetworkCertificate.Tests.ps1 b/tests/Remove-DbaNetworkCertificate.Tests.ps1 index d6eca07089..9c88b904d5 100644 --- a/tests/Remove-DbaNetworkCertificate.Tests.ps1 +++ b/tests/Remove-DbaNetworkCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaNetworkCertificate).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaPfDataCollectorCounter.Tests.ps1 b/tests/Remove-DbaPfDataCollectorCounter.Tests.ps1 index 3e1a6dcc1a..b7682379d7 100644 --- a/tests/Remove-DbaPfDataCollectorCounter.Tests.ps1 +++ b/tests/Remove-DbaPfDataCollectorCounter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaPfDataCollectorCounter).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'Collector', 'Counter', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','Collector','Counter','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaPfDataCollectorSet.Tests.ps1 b/tests/Remove-DbaPfDataCollectorSet.Tests.ps1 index 4a9c4fd093..bd6cb3bba6 100644 --- a/tests/Remove-DbaPfDataCollectorSet.Tests.ps1 +++ b/tests/Remove-DbaPfDataCollectorSet.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaPfDataCollectorSet).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaSpn.Tests.ps1 b/tests/Remove-DbaSpn.Tests.ps1 index d1c649c0af..03371192ce 100644 --- a/tests/Remove-DbaSpn.Tests.ps1 +++ b/tests/Remove-DbaSpn.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaSpn).Parameters.Keys - $knownParameters = 'SPN', 'ServiceAccount', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SPN','ServiceAccount','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaTrace.Tests.ps1 b/tests/Remove-DbaTrace.Tests.ps1 index 556a5e7941..3e05578cf3 100644 --- a/tests/Remove-DbaTrace.Tests.ps1 +++ b/tests/Remove-DbaTrace.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaTrace).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Id', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Id','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaXESession.Tests.ps1 b/tests/Remove-DbaXESession.Tests.ps1 index f5ba99af75..71b1a51110 100644 --- a/tests/Remove-DbaXESession.Tests.ps1 +++ b/tests/Remove-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaXESession).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Session', 'AllSessions', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Session','AllSessions','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Remove-DbaXESmartTarget.Tests.ps1 b/tests/Remove-DbaXESmartTarget.Tests.ps1 index d88d8ee184..afd171ab05 100644 --- a/tests/Remove-DbaXESmartTarget.Tests.ps1 +++ b/tests/Remove-DbaXESmartTarget.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Remove-DbaXESmartTarget).Parameters.Keys - $knownParameters = 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Rename-DbaDatabase.Tests.ps1 b/tests/Rename-DbaDatabase.Tests.ps1 index 95b450d327..034a0aa550 100644 --- a/tests/Rename-DbaDatabase.Tests.ps1 +++ b/tests/Rename-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 16 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Rename-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'AllDatabases', 'DatabaseName', 'FileGroupName', 'LogicalName', 'FileName', 'ReplaceBefore', 'Force', 'Move', 'SetOffline', 'Preview', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','AllDatabases','DatabaseName','FileGroupName','LogicalName','FileName','ReplaceBefore','Force','Move','SetOffline','Preview','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Rename-DbaLogin.Tests.ps1 b/tests/Rename-DbaLogin.Tests.ps1 index d5dc7ac198..594db1c72c 100644 --- a/tests/Rename-DbaLogin.Tests.ps1 +++ b/tests/Rename-DbaLogin.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Rename-DbaLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'NewLogin', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','NewLogin','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Repair-DbaDbMirror.Tests.ps1 b/tests/Repair-DbaDbMirror.Tests.ps1 index 85e211327c..b7df21331c 100644 --- a/tests/Repair-DbaDbMirror.Tests.ps1 +++ b/tests/Repair-DbaDbMirror.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Repair-DbaDbMirror).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Repair-DbaDbOrphanUser.Tests.ps1 b/tests/Repair-DbaDbOrphanUser.Tests.ps1 index 90b6fad0b7..1e7c42dd6c 100644 --- a/tests/Repair-DbaDbOrphanUser.Tests.ps1 +++ b/tests/Repair-DbaDbOrphanUser.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $commonParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Repair-DbaDbOrphanUser).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Users', 'RemoveNotExisting', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $commonParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Users','RemoveNotExisting','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Repair-DbaServerName.Tests.ps1 b/tests/Repair-DbaServerName.Tests.ps1 index 704add148d..1b54478e7e 100644 --- a/tests/Repair-DbaServerName.Tests.ps1 +++ b/tests/Repair-DbaServerName.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Repair-DbaServerName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AutoFix', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AutoFix','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Reset-DbaAdmin.Tests.ps1 b/tests/Reset-DbaAdmin.Tests.ps1 index df5f3991fa..c6dec0f39a 100644 --- a/tests/Reset-DbaAdmin.Tests.ps1 +++ b/tests/Reset-DbaAdmin.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Reset-DbaAdmin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'SecurePassword', 'Force', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','SecurePassword','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Resolve-DbaNetworkName.Tests.ps1 b/tests/Resolve-DbaNetworkName.Tests.ps1 index 77556b9a18..5f61d93bfd 100644 --- a/tests/Resolve-DbaNetworkName.Tests.ps1 +++ b/tests/Resolve-DbaNetworkName.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Resolve-DbaNetworkName).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Turbo', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Turbo','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } Context "Testing basic name resolution" { diff --git a/tests/Restart-DbaService.Tests.ps1 b/tests/Restart-DbaService.Tests.ps1 index 13d345c481..2ad6e506e8 100644 --- a/tests/Restart-DbaService.Tests.ps1 +++ b/tests/Restart-DbaService.Tests.ps1 @@ -5,15 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Restart-DbaService).Parameters.Keys - $knownParameters = 'ComputerName', 'InstanceName', 'Type', 'InputObject', 'Timeout', 'Credential', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','InstanceName','Type','InputObject','Timeout','Credential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Restore-DbaBackupFromDirectory.Tests.ps1 b/tests/Restore-DbaBackupFromDirectory.Tests.ps1 index 58dc20a2d1..4091b4416a 100644 --- a/tests/Restore-DbaBackupFromDirectory.Tests.ps1 +++ b/tests/Restore-DbaBackupFromDirectory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Restore-DbaBackupFromDirectory).Parameters.Keys - $knownParameters = 'SqlInstance', 'Path', 'NoRecovery', 'ReuseSourceFolderStructure', 'SqlCredential', 'Force' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Path','NoRecovery','ReuseSourceFolderStructure','SqlCredential','Force' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Restore-DbaDatabase.Tests.ps1 b/tests/Restore-DbaDatabase.Tests.ps1 index a7e842f8d0..96710f7687 100644 --- a/tests/Restore-DbaDatabase.Tests.ps1 +++ b/tests/Restore-DbaDatabase.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 45 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Restore-DbaDatabase).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'DatabaseName', 'DestinationDataDirectory', 'DestinationLogDirectory', 'DestinationFileStreamDirectory', 'RestoreTime', 'NoRecovery', 'WithReplace', 'XpDirTree', 'OutputScriptOnly', 'VerifyOnly', 'MaintenanceSolutionBackup', 'FileMapping', 'IgnoreLogBackup', 'useDestinationDefaultDirectories', 'ReuseSourceFolderStructure', 'DestinationFilePrefix', 'RestoredDatabaseNamePrefix', 'TrustDbBackupHistory', 'MaxTransferSize', 'BlockSize', 'BufferCount', 'DirectoryRecurse', 'EnableException', 'StandbyDirectory', 'Continue', 'AzureCredential', 'ReplaceDbNameInFile', 'DestinationFileSuffix', 'Recover', 'KeepCDC', 'AllowContinue', 'GetBackupInformation', 'StopAfterGetBackupInformation', 'SelectBackupInformation', 'StopAfterSelectBackupInformation', 'FormatBackupInformation', 'StopAfterFormatBackupInformation', 'TestBackupInformation', 'StopAfterTestBackupInformation', 'PageRestore', 'PageRestoreTailFolder', 'StatementTimeout' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','DatabaseName','DestinationDataDirectory','DestinationLogDirectory','DestinationFileStreamDirectory','RestoreTime','NoRecovery','WithReplace','XpDirTree','OutputScriptOnly','VerifyOnly','MaintenanceSolutionBackup','FileMapping','IgnoreLogBackup','UseDestinationDefaultDirectories','ReuseSourceFolderStructure','DestinationFilePrefix','RestoredDatabaseNamePrefix','TrustDbBackupHistory','MaxTransferSize','BlockSize','BufferCount','DirectoryRecurse','EnableException','StandbyDirectory','Continue','AzureCredential','ReplaceDbNameInFile','DestinationFileSuffix','Recover','KeepCDC','AllowContinue','GetBackupInformation','StopAfterGetBackupInformation','SelectBackupInformation','StopAfterSelectBackupInformation','FormatBackupInformation','StopAfterFormatBackupInformation','TestBackupInformation','StopAfterTestBackupInformation','PageRestore','PageRestoreTailFolder','StatementTimeout' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Restore-DbaDbCertificate.Tests.ps1 b/tests/Restore-DbaDbCertificate.Tests.ps1 index 7d4dc90388..b6510ac90b 100644 --- a/tests/Restore-DbaDbCertificate.Tests.ps1 +++ b/tests/Restore-DbaDbCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Restore-DbaDbCertificate).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'Database', 'SecurePassword', 'EncryptionPassword', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','EncryptionPassword','Database','SecurePassword','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Restore-DbaDbSnapshot.Tests.ps1 b/tests/Restore-DbaDbSnapshot.Tests.ps1 index b8f0817b45..22ba0d2a1c 100644 --- a/tests/Restore-DbaDbSnapshot.Tests.ps1 +++ b/tests/Restore-DbaDbSnapshot.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Restore-DbaDbSnapshot).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Snapshot', 'InputObject', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Snapshot','InputObject','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Resume-DbaAgDbDataMovement.Tests.ps1 b/tests/Resume-DbaAgDbDataMovement.Tests.ps1 index 094c762b17..18d7a3bfc8 100644 --- a/tests/Resume-DbaAgDbDataMovement.Tests.ps1 +++ b/tests/Resume-DbaAgDbDataMovement.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Resume-DbaAgDbDataMovement).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Database', 'InputObject', 'EnableException' - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Database','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Revoke-DbaAgPermission.Tests.ps1 b/tests/Revoke-DbaAgPermission.Tests.ps1 index e0423cd638..c9bd3c6fae 100644 --- a/tests/Revoke-DbaAgPermission.Tests.ps1 +++ b/tests/Revoke-DbaAgPermission.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Revoke-DbaAgPermission).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'AvailabilityGroup', 'Type', 'Permission', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','AvailabilityGroup','Type','Permission','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Save-DbaDiagnosticQueryScript.Tests.ps1 b/tests/Save-DbaDiagnosticQueryScript.Tests.ps1 index 88b5092561..4a6cb25174 100644 --- a/tests/Save-DbaDiagnosticQueryScript.Tests.ps1 +++ b/tests/Save-DbaDiagnosticQueryScript.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Save-DbaDiagnosticQueryScript).Parameters.Keys - $knownParameters = 'Path', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Path','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Select-DbaBackupInformation.Tests.ps1 b/tests/Select-DbaBackupInformation.Tests.ps1 index 6fd0c61310..1512c2786c 100644 --- a/tests/Select-DbaBackupInformation.Tests.ps1 +++ b/tests/Select-DbaBackupInformation.Tests.ps1 @@ -3,26 +3,18 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" Describe "$commandname Unit Tests" -Tag 'UnitTests' { - InModuleScope dbatools { - Context "Empty TLog Backup Issues" { - $Header = ConvertFrom-Json -InputObject (Get-Content $PSScriptRoot\..\tests\ObjectDefinitions\BackupRestore\RawInput\EmptyTlogData.json -raw) - $header | Add-Member -Type NoteProperty -Name FullName -Value 1 - $Output = Select-DbaBackupInformation -BackupHistory $header #-EnableException:$true - - It "Should return an array of 3 items" { - $Output.count | Should be 2 - } - It "Should return 1 Full backups" { - ($Output | Where-Object { $_.BackupTypeDescription -eq 'Database' } | Measure-Object).count | Should Be 1 - } - It "Should return 0 Diff backups" { - ($Output | Where-Object { $_.BackupTypeDescription -eq 'Database Differential' } | Measure-Object).count | Should Be 0 - } - It "Should return 2 log backups" { - ($Output | Where-Object { $_.BackupTypeDescription -eq 'Transaction Log' } | Measure-Object).count | Should Be 1 - } + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'BackupHistory','RestoreTime','IgnoreLogs','IgnoreDiffs','DatabaseName','ServerName','ContinuePoints','LastRestoreType','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } - Context "General Diff Restore" { + } +} +Describe "$commandname Integration Tests" -Tag 'IntegrationTests' { + InModuleScope dbatools { + Context "General Diff Restore" { $Header = ConvertFrom-Json -InputObject (Get-Content $PSScriptRoot\..\tests\ObjectDefinitions\BackupRestore\RawInput\DiffRestore.json -raw) $header | Add-Member -Type NoteProperty -Name FullName -Value 1 $Output = Select-DbaBackupInformation -BackupHistory $header -EnableException:$true diff --git a/tests/Select-DbaObject.Tests.ps1 b/tests/Select-DbaObject.Tests.ps1 index 674d02ea82..6f794abe8d 100644 --- a/tests/Select-DbaObject.Tests.ps1 +++ b/tests/Select-DbaObject.Tests.ps1 @@ -3,6 +3,17 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" Describe "$commandname Unit Tests" -Tag "UnitTests" { + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','Property','ExcludeProperty','ExpandProperty','Unique','Last','First','Skip','SkipLast','Wait','Index','ShowProperty','ShowExcludeProperty','TypeName','KeepInputObject' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} + +Describe "$commandname Integration Tests" -Tag "IntegrationTests" { $global:object = [PSCustomObject]@{ Foo = 42 Bar = 18 diff --git a/tests/Set-DbaAgListener.Tests.ps1 b/tests/Set-DbaAgListener.Tests.ps1 index 4d9dc01282..b443d01afa 100644 --- a/tests/Set-DbaAgListener.Tests.ps1 +++ b/tests/Set-DbaAgListener.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgListener).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Listener', 'Port', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Listener','Port','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Set-DbaAgReplica.Tests.ps1 b/tests/Set-DbaAgReplica.Tests.ps1 index 94804b70c0..3230579019 100644 --- a/tests/Set-DbaAgReplica.Tests.ps1 +++ b/tests/Set-DbaAgReplica.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgReplica).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Replica', 'AvailabilityMode', 'InputObject', 'EnableException', 'FailoverMode', 'BackupPriority', 'EndpointUrl', 'ConnectionModeInPrimaryRole', 'ConnectionModeInSecondaryRole', 'ReadonlyRoutingConnectionUrl', 'SeedingMode' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Replica','AvailabilityMode','FailoverMode','BackupPriority','ConnectionModeInPrimaryRole','ConnectionModeInSecondaryRole','SeedingMode','EndpointUrl','ReadonlyRoutingConnectionUrl','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentAlert.Tests.ps1 b/tests/Set-DbaAgentAlert.Tests.ps1 index ea6fc35f53..c5fa3e40df 100644 --- a/tests/Set-DbaAgentAlert.Tests.ps1 +++ b/tests/Set-DbaAgentAlert.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentAlert).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} - [object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Alert', 'NewName', 'Enabled', 'Disabled', 'Force', 'InputObject', 'EnableException' + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Alert','NewName','Enabled','Disabled','Force','InputObject','EnableException' $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters It "Should only contain our specific parameters" { - (@(Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params).Count ) | Should Be 0 + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentJob.Tests.ps1 b/tests/Set-DbaAgentJob.Tests.ps1 index 771e084cc1..0a98f561fb 100644 --- a/tests/Set-DbaAgentJob.Tests.ps1 +++ b/tests/Set-DbaAgentJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 23 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'Schedule', 'ScheduleId', 'NewName', 'Enabled', 'Disabled', 'Description', 'StartStepId', 'Category', 'OwnerLogin', 'EventLogLevel', 'EmailLevel', 'NetsendLevel', 'PageLevel', 'EmailOperator', 'NetsendOperator', 'PageOperator', 'DeleteLevel', 'Force', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','Schedule','ScheduleId','NewName','Enabled','Disabled','Description','StartStepId','Category','OwnerLogin','EventLogLevel','EmailLevel','NetsendLevel','PageLevel','EmailOperator','NetsendOperator','PageOperator','DeleteLevel','Force','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentJobCategory.Tests.ps1 b/tests/Set-DbaAgentJobCategory.Tests.ps1 index ae34d611fe..7633cd334e 100644 --- a/tests/Set-DbaAgentJobCategory.Tests.ps1 +++ b/tests/Set-DbaAgentJobCategory.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentJobCategory).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Category', 'NewName', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Category','NewName','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentJobOutputFile.Tests.ps1 b/tests/Set-DbaAgentJobOutputFile.Tests.ps1 index 666c6bab8a..ecc258e209 100644 --- a/tests/Set-DbaAgentJobOutputFile.Tests.ps1 +++ b/tests/Set-DbaAgentJobOutputFile.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentJobOutputFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'Step', 'OutputFile', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','Step','OutputFile','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentJobOwner.Tests.ps1 b/tests/Set-DbaAgentJobOwner.Tests.ps1 index 25acac72cf..41d7b4966a 100644 --- a/tests/Set-DbaAgentJobOwner.Tests.ps1 +++ b/tests/Set-DbaAgentJobOwner.Tests.ps1 @@ -4,10 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentJobOwner).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'InputObject', 'Login', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','InputObject','Login','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentJobStep.Tests.ps1 b/tests/Set-DbaAgentJobStep.Tests.ps1 index 1f1e374701..51e733a2be 100644 --- a/tests/Set-DbaAgentJobStep.Tests.ps1 +++ b/tests/Set-DbaAgentJobStep.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 21 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentJobStep).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'StepName', 'NewName', 'Subsystem', 'Command', 'CmdExecSuccessCode', 'OnSuccessAction', 'OnSuccessStepId', 'OnFailAction', 'OnFailStepId', 'Database', 'DatabaseUser', 'RetryAttempts', 'RetryInterval', 'OutputFileName', 'Flag', 'ProxyName', 'EnableException', 'Force' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','StepName','NewName','Subsystem','Command','CmdExecSuccessCode','OnSuccessAction','OnSuccessStepId','OnFailAction','OnFailStepId','Database','DatabaseUser','RetryAttempts','RetryInterval','OutputFileName','Flag','ProxyName','EnableException','Force' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentSchedule.Tests.ps1 b/tests/Set-DbaAgentSchedule.Tests.ps1 index 8be84a4fdd..1150aa4914 100644 --- a/tests/Set-DbaAgentSchedule.Tests.ps1 +++ b/tests/Set-DbaAgentSchedule.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 19 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentSchedule).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ScheduleName', 'NewName', 'Enabled', 'Disabled', 'FrequencyType', 'FrequencyInterval', 'FrequencySubdayType', 'FrequencySubdayInterval', 'FrequencyRelativeInterval', 'FrequencyRecurrenceFactor', 'StartDate', 'EndDate', 'StartTime', 'EndTime', 'EnableException', 'Force' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ScheduleName','NewName','Enabled','Disabled','FrequencyType','FrequencyInterval','FrequencySubdayType','FrequencySubdayInterval','FrequencyRelativeInterval','FrequencyRecurrenceFactor','StartDate','EndDate','StartTime','EndTime','EnableException','Force' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAgentServer.Tests.ps1 b/tests/Set-DbaAgentServer.Tests.ps1 index fdd01609a5..47151a9003 100644 --- a/tests/Set-DbaAgentServer.Tests.ps1 +++ b/tests/Set-DbaAgentServer.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAgentServer).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'InputObject', 'AgentLogLevel', 'AgentMailType', 'AgentShutdownWaitTime', 'DatabaseMailProfile', 'ErrorLogFile', 'IdleCpuDuration', 'IdleCpuPercentage', 'CpuPolling', 'LocalHostAlias', 'LoginTimeout', 'MaximumHistoryRows', 'MaximumJobHistoryRows', 'NetSendRecipient', 'ReplaceAlertTokens', 'SaveInSentFolder', 'SqlAgentAutoStart', 'SqlAgentMailProfile', 'SqlAgentRestart', 'SqlServerRestart', 'WriteOemErrorLog', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','InputObject','AgentLogLevel','AgentMailType','AgentShutdownWaitTime','DatabaseMailProfile','ErrorLogFile','IdleCpuDuration','IdleCpuPercentage','CpuPolling','LocalHostAlias','LoginTimeout','MaximumHistoryRows','MaximumJobHistoryRows','NetSendRecipient','ReplaceAlertTokens','SaveInSentFolder','SqlAgentAutoStart','SqlAgentMailProfile','SqlAgentRestart','SqlServerRestart','WriteOemErrorLog','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaAvailabilityGroup.Tests.ps1 b/tests/Set-DbaAvailabilityGroup.Tests.ps1 index 4d78498490..0329a7e6a0 100644 --- a/tests/Set-DbaAvailabilityGroup.Tests.ps1 +++ b/tests/Set-DbaAvailabilityGroup.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaAvailabilityGroup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'AllAvailabilityGroups', 'DtcSupportEnabled', 'ClusterType', 'AutomatedBackupPreference', 'FailureConditionLevel', 'HealthCheckTimeout', 'BasicAvailabilityGroup', 'DatabaseHealthTrigger', 'IsDistributedAvailabilityGroup', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','AllAvailabilityGroups','DtcSupportEnabled','ClusterType','AutomatedBackupPreference','FailureConditionLevel','HealthCheckTimeout','BasicAvailabilityGroup','DatabaseHealthTrigger','IsDistributedAvailabilityGroup','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaCmConnection.Tests.ps1 b/tests/Set-DbaCmConnection.Tests.ps1 index 81842084a7..ce4cfcbb0d 100644 --- a/tests/Set-DbaCmConnection.Tests.ps1 +++ b/tests/Set-DbaCmConnection.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 21 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaCmConnection).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'UseWindowsCredentials', 'OverrideExplicitCredential', 'OverrideConnectionPolicy', 'DisabledConnectionTypes', 'DisableBadCredentialCache', 'DisableCimPersistence', 'DisableCredentialAutoRegister', 'EnableCredentialFailover', 'WindowsCredentialsAreBad', 'CimWinRMOptions', 'CimDCOMOptions', 'AddBadCredential', 'RemoveBadCredential', 'ClearBadCredential', 'ClearCredential', 'ResetCredential', 'ResetConnectionStatus', 'ResetConfiguration', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','UseWindowsCredentials','OverrideExplicitCredential','OverrideConnectionPolicy','DisabledConnectionTypes','DisableBadCredentialCache','DisableCimPersistence','DisableCredentialAutoRegister','EnableCredentialFailover','WindowsCredentialsAreBad','CimWinRMOptions','CimDCOMOptions','AddBadCredential','RemoveBadCredential','ClearBadCredential','ClearCredential','ResetCredential','ResetConnectionStatus','ResetConfiguration','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaDbCompression.Tests.ps1 b/tests/Set-DbaDbCompression.Tests.ps1 index 0802106cb2..ac3304ea6f 100644 --- a/tests/Set-DbaDbCompression.Tests.ps1 +++ b/tests/Set-DbaDbCompression.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaDbCompression).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'CompressionType', 'MaxRunTime', 'PercentCompression', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','CompressionType','MaxRunTime','PercentCompression','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaDbMirror.Tests.ps1 b/tests/Set-DbaDbMirror.Tests.ps1 index c6e3e7b175..26756ff005 100644 --- a/tests/Set-DbaDbMirror.Tests.ps1 +++ b/tests/Set-DbaDbMirror.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaDbMirror).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Partner', 'Witness', 'SafetyLevel', 'State', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Partner','Witness','SafetyLevel','State','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaDbOwner.Tests.ps1 b/tests/Set-DbaDbOwner.Tests.ps1 index 7acf8e8c27..98ae2ad3ea 100644 --- a/tests/Set-DbaDbOwner.Tests.ps1 +++ b/tests/Set-DbaDbOwner.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaDbOwner).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'TargetLogin', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','TargetLogin','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaDbQueryStoreOption.Tests.ps1 b/tests/Set-DbaDbQueryStoreOption.Tests.ps1 index 6f71365507..8eb8b0178a 100644 --- a/tests/Set-DbaDbQueryStoreOption.Tests.ps1 +++ b/tests/Set-DbaDbQueryStoreOption.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 13 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaDbQueryStoreOption).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'AllDatabases', 'State', 'FlushInterval', 'CollectionInterval', 'MaxSize', 'CaptureMode', 'CleanupMode', 'StaleQueryThreshold', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','AllDatabases','State','FlushInterval','CollectionInterval','MaxSize','CaptureMode','CleanupMode','StaleQueryThreshold','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaDbRecoveryModel.Tests.ps1 b/tests/Set-DbaDbRecoveryModel.Tests.ps1 index bf17b7c076..451ba77b7f 100644 --- a/tests/Set-DbaDbRecoveryModel.Tests.ps1 +++ b/tests/Set-DbaDbRecoveryModel.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaDbRecoveryModel).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'RecoveryModel', 'Database', 'ExcludeDatabase', 'AllDatabases', 'EnableException', 'InputObject' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','RecoveryModel','Database','ExcludeDatabase','AllDatabases','EnableException','InputObject' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaDbState.Tests.ps1 b/tests/Set-DbaDbState.Tests.ps1 index c1d0a7bd6a..4bdfbfe1ad 100644 --- a/tests/Set-DbaDbState.Tests.ps1 +++ b/tests/Set-DbaDbState.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 17 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaDbState).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'AllDatabases', 'ReadOnly', 'ReadWrite', 'Online', 'Offline', 'Emergency', 'Detached', 'SingleUser', 'RestrictedUser', 'MultiUser', 'Force', 'EnableException', 'InputObject' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','AllDatabases','ReadOnly','ReadWrite','Online','Offline','Emergency','Detached','SingleUser','RestrictedUser','MultiUser','Force','EnableException','InputObject' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaEndpoint.Tests.ps1 b/tests/Set-DbaEndpoint.Tests.ps1 index 7da22720ea..15c40e95a1 100644 --- a/tests/Set-DbaEndpoint.Tests.ps1 +++ b/tests/Set-DbaEndpoint.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaEndpoint).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Owner', 'Type', 'Endpoint', 'AllEndpoints', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EndPoint','Owner','Type','AllEndpoints','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Set-DbaErrorLogConfig.Tests.ps1 b/tests/Set-DbaErrorLogConfig.Tests.ps1 index 3b3d6129f7..0eaba628cb 100644 --- a/tests/Set-DbaErrorLogConfig.Tests.ps1 +++ b/tests/Set-DbaErrorLogConfig.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaErrorLogConfig).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'LogSize', 'LogCount', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','LogCount','LogSize','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaLogin.Tests.ps1 b/tests/Set-DbaLogin.Tests.ps1 index 88ac473026..4ed810f047 100644 --- a/tests/Set-DbaLogin.Tests.ps1 +++ b/tests/Set-DbaLogin.Tests.ps1 @@ -4,11 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $command = Get-Command $CommandName - [object[]]$params = (Get-ChildItem function:\Set-DbaLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'SecurePassword', 'DefaultDatabase', 'Unlock', 'MustChange', 'NewName', 'Disable', 'Enable', 'DenyLogin', 'GrantLogin', 'PasswordPolicyEnforced', 'AddRole', 'RemoveRole', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','SecurePassword','DefaultDatabase','Unlock','MustChange','NewName','Disable','Enable','DenyLogin','GrantLogin','PasswordPolicyEnforced','AddRole','RemoveRole','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } $systemRoles = @( @@ -23,6 +23,8 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { @{role = 'sysadmin'} ) + $command = Get-Command $CommandName + It "Validates -AddRole contains " -TestCases $systemRoles { param ($role) diff --git a/tests/Set-DbaMaxDop.Tests.ps1 b/tests/Set-DbaMaxDop.Tests.ps1 index 1c3a078d3f..6c3529fd00 100644 --- a/tests/Set-DbaMaxDop.Tests.ps1 +++ b/tests/Set-DbaMaxDop.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag "UnitTests", Set-DbaMaxDop { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'MaxDop', 'InputObject', 'AllDatabases', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','MaxDop','InputObject','AllDatabases','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } diff --git a/tests/Set-DbaMaxMemory.Tests.ps1 b/tests/Set-DbaMaxMemory.Tests.ps1 index af2bd44c3a..c433836efb 100644 --- a/tests/Set-DbaMaxMemory.Tests.ps1 +++ b/tests/Set-DbaMaxMemory.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Max', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Max','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaNetworkCertificate.Tests.ps1 b/tests/Set-DbaNetworkCertificate.Tests.ps1 index b490f852c9..71f0a0a066 100644 --- a/tests/Set-DbaNetworkCertificate.Tests.ps1 +++ b/tests/Set-DbaNetworkCertificate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaNetworkCertificate).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'Certificate', 'Thumbprint', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','Certificate','Thumbprint','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaPowerPlan.Tests.ps1 b/tests/Set-DbaPowerPlan.Tests.ps1 index e1b9ccd7e4..92a86d6b03 100644 --- a/tests/Set-DbaPowerPlan.Tests.ps1 +++ b/tests/Set-DbaPowerPlan.Tests.ps1 @@ -4,16 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $knownParameters = 'ComputerName', 'Credential', 'PowerPlan', 'CustomPowerPlan', 'EnableException', 'InputObject' - $paramCount = $knownParameters.Count - $defaultParamCount = 13 - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','PowerPlan','CustomPowerPlan','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaPrivilege.Tests.ps1 b/tests/Set-DbaPrivilege.Tests.ps1 index eebe6041e5..0a7897c395 100644 --- a/tests/Set-DbaPrivilege.Tests.ps1 +++ b/tests/Set-DbaPrivilege.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaPrivilege).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Type', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Type','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaSpConfigure.Tests.ps1 b/tests/Set-DbaSpConfigure.Tests.ps1 index aa8874c22e..37193d473d 100644 --- a/tests/Set-DbaSpConfigure.Tests.ps1 +++ b/tests/Set-DbaSpConfigure.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaSpConfigure).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Value', 'Name', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Value','Name','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaSpn.Tests.ps1 b/tests/Set-DbaSpn.Tests.ps1 index 2d0c79393a..5c8676eb2e 100644 --- a/tests/Set-DbaSpn.Tests.ps1 +++ b/tests/Set-DbaSpn.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaSpn).Parameters.Keys - $knownParameters = 'SPN', 'ServiceAccount', 'Credential', 'NoDelegation', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SPN','ServiceAccount','Credential','NoDelegation','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaStartupParameter.Tests.ps1 b/tests/Set-DbaStartupParameter.Tests.ps1 index 5f3d1f8623..f801124dce 100644 --- a/tests/Set-DbaStartupParameter.Tests.ps1 +++ b/tests/Set-DbaStartupParameter.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 21 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaStartupParameter).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Credential', 'MasterData', 'MasterLog', 'ErrorLog', 'TraceFlags', 'CommandPromptStart', 'MinimalStart', 'MemoryToReserve', 'SingleUser', 'SingleUserDetails', 'NoLoggingToWinEvents', 'StartAsNamedInstance', 'DisableMonitoring', 'IncreasedExtents', 'TraceFlagsOverride', 'StartUpConfig', 'Offline', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','MasterData','MasterLog','ErrorLog','TraceFlags','CommandPromptStart','MinimalStart','MemoryToReserve','SingleUser','SingleUserDetails','NoLoggingToWinEvents','StartAsNamedInstance','DisableMonitoring','IncreasedExtents','TraceFlagsOverride','StartUpConfig','Offline','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaTcpPort.Tests.ps1 b/tests/Set-DbaTcpPort.Tests.ps1 index c998419ee2..2ae1d6d347 100644 --- a/tests/Set-DbaTcpPort.Tests.ps1 +++ b/tests/Set-DbaTcpPort.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaTcpPort).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'Port', 'IpAddress', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','Port','IpAddress','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Set-DbaTempDbConfig.Tests.ps1 b/tests/Set-DbaTempDbConfig.Tests.ps1 index 70144835ff..c9eb34846b 100644 --- a/tests/Set-DbaTempDbConfig.Tests.ps1 +++ b/tests/Set-DbaTempDbConfig.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 13 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Set-DbaTempDbConfig).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'DataFileCount', 'DataFileSize', 'LogFileSize', 'DataFileGrowth', 'LogFileGrowth', 'DataPath', 'LogPath', 'OutFile', 'OutputScriptOnly', 'DisableGrowth', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','DataFileCount','DataFileSize','LogFileSize','DataFileGrowth','LogFileGrowth','DataPath','LogPath','OutFile','OutputScriptOnly','DisableGrowth','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Show-DbaDbList.Tests.ps1 b/tests/Show-DbaDbList.Tests.ps1 index c46f0de4f9..9af82002be 100644 --- a/tests/Show-DbaDbList.Tests.ps1 +++ b/tests/Show-DbaDbList.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Show-DbaDbList).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Title', 'Header', 'DefaultDb' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Title','Header','DefaultDb' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Show-DbaServerFileSystem.Tests.ps1 b/tests/Show-DbaServerFileSystem.Tests.ps1 index 8a6767e548..a323cc8501 100644 --- a/tests/Show-DbaServerFileSystem.Tests.ps1 +++ b/tests/Show-DbaServerFileSystem.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Show-DbaServerFileSystem).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaAgentJob.Tests.ps1 b/tests/Start-DbaAgentJob.Tests.ps1 index f4f7ea7309..b565265fbc 100644 --- a/tests/Start-DbaAgentJob.Tests.ps1 +++ b/tests/Start-DbaAgentJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Start-DbaAgentJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'InputObject', 'AllJobs', 'Wait', 'WaitPeriod', 'SleepPeriod', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','InputObject','AllJobs','Wait','WaitPeriod','SleepPeriod','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaEndpoint.Tests.ps1 b/tests/Start-DbaEndpoint.Tests.ps1 index 809792d3aa..d7f8c4f6af 100644 --- a/tests/Start-DbaEndpoint.Tests.ps1 +++ b/tests/Start-DbaEndpoint.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EndPoint', 'AllEndpoints', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EndPoint','AllEndpoints','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaMigration.Tests.ps1 b/tests/Start-DbaMigration.Tests.ps1 index 0e709a8113..9f14a2285b 100644 --- a/tests/Start-DbaMigration.Tests.ps1 +++ b/tests/Start-DbaMigration.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $knownParameters = 'Source', 'Destination', 'DetachAttach', 'Reattach', 'BackupRestore', 'SharedPath', 'WithReplace', 'NoRecovery', 'SetSourceReadOnly', 'ReuseSourceFolderStructure', 'IncludeSupportDbs', 'SourceSqlCredential', 'DestinationSqlCredential', 'Exclude', 'DisableJobsOnDestination', 'DisableJobsOnSource', 'ExcludeSaRename', 'UseLastBackup', 'Continue', 'Force', 'EnableException' - $paramCount = $knownParameters.Count - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Start-DbaMigration).Parameters.Keys - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','Destination','DetachAttach','Reattach','BackupRestore','SharedPath','WithReplace','NoRecovery','SetSourceReadOnly','ReuseSourceFolderStructure','IncludeSupportDbs','SourceSqlCredential','DestinationSqlCredential','Exclude','DisableJobsOnDestination','DisableJobsOnSource','ExcludeSaRename','UseLastBackup','Continue','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaPfDataCollectorSet.Tests.ps1 b/tests/Start-DbaPfDataCollectorSet.Tests.ps1 index 62796e200e..f4c88a43ec 100644 --- a/tests/Start-DbaPfDataCollectorSet.Tests.ps1 +++ b/tests/Start-DbaPfDataCollectorSet.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Start-DbaPfDataCollectorSet).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'InputObject', 'NoWait', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','InputObject','NoWait','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaService.Tests.ps1 b/tests/Start-DbaService.Tests.ps1 index f9178f7f48..641b6128bd 100644 --- a/tests/Start-DbaService.Tests.ps1 +++ b/tests/Start-DbaService.Tests.ps1 @@ -5,15 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Start-DbaService).Parameters.Keys - $knownParameters = 'ComputerName', 'InstanceName', 'Type', 'InputObject', 'Timeout', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','InstanceName','Type','InputObject','Timeout','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaTrace.Tests.ps1 b/tests/Start-DbaTrace.Tests.ps1 index 644aef95fd..65f5e24cd6 100644 --- a/tests/Start-DbaTrace.Tests.ps1 +++ b/tests/Start-DbaTrace.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Start-DbaTrace).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Id', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Id','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaXESession.Tests.ps1 b/tests/Start-DbaXESession.Tests.ps1 index 20d8456528..a978751c77 100644 --- a/tests/Start-DbaXESession.Tests.ps1 +++ b/tests/Start-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Start-DbaXESession).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Session', 'StopAt', 'AllSessions', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Session','StopAt','AllSessions','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Start-DbaXESmartTarget.Tests.ps1 b/tests/Start-DbaXESmartTarget.Tests.ps1 index 27b5361136..6a62f1198a 100644 --- a/tests/Start-DbaXESmartTarget.Tests.ps1 +++ b/tests/Start-DbaXESmartTarget.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Start-DbaXESmartTarget).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'Session', 'FailOnProcessingError', 'Responder', 'Template', 'NotAsJob', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','Session','FailOnProcessingError','Responder','Template','NotAsJob','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaAgentJob.Tests.ps1 b/tests/Stop-DbaAgentJob.Tests.ps1 index 81be3d6512..33efaf0771 100644 --- a/tests/Stop-DbaAgentJob.Tests.ps1 +++ b/tests/Stop-DbaAgentJob.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Stop-DbaAgentJob).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'InputObject', 'Wait', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','InputObject','Wait','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaEndpoint.Tests.ps1 b/tests/Stop-DbaEndpoint.Tests.ps1 index 7580aad1a8..3eeac98ed6 100644 --- a/tests/Stop-DbaEndpoint.Tests.ps1 +++ b/tests/Stop-DbaEndpoint.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'EndPoint', 'AllEndpoints', 'InputObject', 'EnableException' - $SupportShouldProcess = $true - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EndPoint','AllEndpoints','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaPfDataCollectorSet.Tests.ps1 b/tests/Stop-DbaPfDataCollectorSet.Tests.ps1 index c7ba5973d6..7d5143c6a2 100644 --- a/tests/Stop-DbaPfDataCollectorSet.Tests.ps1 +++ b/tests/Stop-DbaPfDataCollectorSet.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Stop-DbaPfDataCollectorSet).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CollectorSet', 'InputObject', 'NoWait', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CollectorSet','InputObject','NoWait','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaProcess.Tests.ps1 b/tests/Stop-DbaProcess.Tests.ps1 index bc7599e4a3..dae504b877 100644 --- a/tests/Stop-DbaProcess.Tests.ps1 +++ b/tests/Stop-DbaProcess.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Stop-DbaProcess).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Spid', 'ExcludeSpid', 'Database', 'Login', 'Hostname', 'Program', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Spid','ExcludeSpid','Database','Login','Hostname','Program','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaService.Tests.ps1 b/tests/Stop-DbaService.Tests.ps1 index c72a489b45..df38a718d8 100644 --- a/tests/Stop-DbaService.Tests.ps1 +++ b/tests/Stop-DbaService.Tests.ps1 @@ -5,15 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 8 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Stop-DbaService).Parameters.Keys - $knownParameters = 'ComputerName', 'InstanceName', 'Type', 'InputObject', 'Timeout', 'Credential', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','InstanceName','Type','InputObject','Timeout','Credential','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaTrace.Tests.ps1 b/tests/Stop-DbaTrace.Tests.ps1 index d9fb2f5ce4..24533d5d7d 100644 --- a/tests/Stop-DbaTrace.Tests.ps1 +++ b/tests/Stop-DbaTrace.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Stop-DbaTrace).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Id', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Id','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaXESession.Tests.ps1 b/tests/Stop-DbaXESession.Tests.ps1 index 1a433f44a4..ed1c8acff2 100644 --- a/tests/Stop-DbaXESession.Tests.ps1 +++ b/tests/Stop-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Stop-DbaXESession).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Session', 'AllSessions', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Session','AllSessions','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-DbaXESmartTarget.Tests.ps1 b/tests/Stop-DbaXESmartTarget.Tests.ps1 index 33f7200aec..afd171ab05 100644 --- a/tests/Stop-DbaXESmartTarget.Tests.ps1 +++ b/tests/Stop-DbaXESmartTarget.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Stop-DbaXESmartTarget).Parameters.Keys - $knownParameters = 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Stop-Function.Tests.ps1 b/tests/Stop-Function.Tests.ps1 index ce6d692a15..9a97eb97df 100644 --- a/tests/Stop-Function.Tests.ps1 +++ b/tests/Stop-Function.Tests.ps1 @@ -6,15 +6,11 @@ $PSDefaultParameterValues.Remove('*:WarningAction') Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 14 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Stop-Function).Parameters.Keys - $knownParameters = 'Message', 'Category', 'ErrorRecord', 'Tag', 'FunctionName', 'File', 'Line', 'Target', 'Exception', 'OverrideExceptionMessage', 'Continue', 'SilentlyContinue', 'ContinueLabel', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Message', 'Category', 'ErrorRecord', 'Tag', 'FunctionName', 'File', 'Line', 'Target', 'Exception', 'OverrideExceptionMessage', 'Continue', 'SilentlyContinue', 'ContinueLabel', 'EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } diff --git a/tests/Suspend-DbaAgDbDataMovement.Tests.ps1 b/tests/Suspend-DbaAgDbDataMovement.Tests.ps1 index c376b86d7c..e1f5349f3c 100644 --- a/tests/Suspend-DbaAgDbDataMovement.Tests.ps1 +++ b/tests/Suspend-DbaAgDbDataMovement.Tests.ps1 @@ -4,19 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$commandname Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Suspend-DbaAgDbDataMovement).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'Database', 'InputObject', 'EnableException' - it "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','AvailabilityGroup','Database','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Sync-DbaLoginPermission.Tests.ps1 b/tests/Sync-DbaLoginPermission.Tests.ps1 index 603561c4f9..43d0cd9ae3 100644 --- a/tests/Sync-DbaLoginPermission.Tests.ps1 +++ b/tests/Sync-DbaLoginPermission.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Sync-DbaLoginPermission).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Login', 'ExcludeLogin', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Login','ExcludeLogin','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaJobOwner.Tests.ps1 b/tests/Test-DbaAgentJobOwner.Tests.ps1 similarity index 73% rename from tests/Test-DbaJobOwner.Tests.ps1 rename to tests/Test-DbaAgentJobOwner.Tests.ps1 index ec28091f78..b319666e72 100644 --- a/tests/Test-DbaJobOwner.Tests.ps1 +++ b/tests/Test-DbaAgentJobOwner.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaAgentJobOwner).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Job', 'ExcludeJob', 'Login', 'EnableException', 'Detailed' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Job','ExcludeJob','Login','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaBackupInformation.Tests.ps1 b/tests/Test-DbaBackupInformation.Tests.ps1 index d71ed0e7ef..89d11c51fa 100644 --- a/tests/Test-DbaBackupInformation.Tests.ps1 +++ b/tests/Test-DbaBackupInformation.Tests.ps1 @@ -3,53 +3,64 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" Describe "$commandname Unit Tests" -Tag 'UnitTests' { - InModuleScope dbatools { - Context "Everything as it should" { - $BackupHistory = Import-CliXml $PSScriptRoot\..\tests\ObjectDefinitions\BackupRestore\RawInput\CleanFormatDbaInformation.xml - $BackupHistory = $BackupHistory | Format-DbaBackupInformation - Mock Connect-SqlInstance -MockWith { - $obj = [PSCustomObject]@{ - Name = 'BASEName' - NetName = 'BASENetName' - InstanceName = 'BASEInstanceName' - DomainInstanceName = 'BASEDomainInstanceName' - InstallDataDirectory = 'BASEInstallDataDirectory' - ErrorLogPath = 'BASEErrorLog_{0}_{1}_{2}_Path' -f "'", '"', ']' - ServiceName = 'BASEServiceName' - VersionMajor = 9 - ConnectionContext = New-Object PSObject - } - Add-Member -InputObject $obj.ConnectionContext -Name ConnectionString -MemberType NoteProperty -Value 'put=an=equal=in=it' - Add-Member -InputObject $obj -Name Query -MemberType ScriptMethod -Value { - param($query) - if ($query -eq "SELECT DB_NAME(database_id) AS Name, physical_name AS PhysicalName FROM sys.master_files") { - return @( - @{ "Name" = "master" - "PhysicalName" = "C:\temp\master.mdf" - } - ) - } - } - $obj.PSObject.TypeNames.Clear() - $obj.PSObject.TypeNames.Add("Microsoft.SqlServer.Management.Smo.Server") - return $obj - } - Mock Get-DbaDatabase { $null } + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'BackupHistory','SqlInstance','SqlCredential','WithReplace','Continue','VerifyOnly','OutputScriptOnly','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} - Mock New-DbaDirectory {$true} - Mock Test-DbaPath { [pscustomobject]@{ - FilePath = 'does\exists' - FileExists = $true +Describe "$commandname Integration Tests" -Tag 'IntegrationTests' { +InModuleScope dbatools { + Context "Everything as it should" { + $BackupHistory = Import-CliXml $PSScriptRoot\..\tests\ObjectDefinitions\BackupRestore\RawInput\CleanFormatDbaInformation.xml + $BackupHistory = $BackupHistory | Format-DbaBackupInformation + Mock Connect-SqlInstance -MockWith { + $obj = [PSCustomObject]@{ + Name = 'BASEName' + NetName = 'BASENetName' + InstanceName = 'BASEInstanceName' + DomainInstanceName = 'BASEDomainInstanceName' + InstallDataDirectory = 'BASEInstallDataDirectory' + ErrorLogPath = 'BASEErrorLog_{0}_{1}_{2}_Path' -f "'", '"', ']' + ServiceName = 'BASEServiceName' + VersionMajor = 9 + ConnectionContext = New-Object PSObject + } + Add-Member -InputObject $obj.ConnectionContext -Name ConnectionString -MemberType NoteProperty -Value 'put=an=equal=in=it' + Add-Member -InputObject $obj -Name Query -MemberType ScriptMethod -Value { + param($query) + if ($query -eq "SELECT DB_NAME(database_id) AS Name, physical_name AS PhysicalName FROM sys.master_files") { + return @( + @{ "Name" = "master" + "PhysicalName" = "C:\temp\master.mdf" + } + ) } } - Mock New-DbaDirectory {$True} - It "Should pass as all systems Green" { - $output = $BackupHistory | Test-DbaBackupInformation -SqlServer NotExist -WarningVariable warnvar -WarningAction SilentlyContinue - ($output.Count) -gt 0 | Should be $true - $false -in ($Output.IsVerified) | Should be $False - ($null -ne $WarnVar) | Should be $True + $obj.PSObject.TypeNames.Clear() + $obj.PSObject.TypeNames.Add("Microsoft.SqlServer.Management.Smo.Server") + return $obj + } + Mock Get-DbaDatabase { $null } + + Mock New-DbaDirectory {$true} + Mock Test-DbaPath { [pscustomobject]@{ + FilePath = 'does\exists' + FileExists = $true } } + Mock New-DbaDirectory {$True} + It "Should pass as all systems Green" { + $output = $BackupHistory | Test-DbaBackupInformation -SqlServer NotExist -WarningVariable warnvar -WarningAction SilentlyContinue + ($output.Count) -gt 0 | Should be $true + $false -in ($Output.IsVerified) | Should be $False + ($null -ne $WarnVar) | Should be $True + } + } Context "Not being able to see backups is bad" { $BackupHistory = Import-CliXml $PSScriptRoot\..\tests\ObjectDefinitions\BackupRestore\RawInput\CleanFormatDbaInformation.xml $BackupHistory = $BackupHistory | Format-DbaBackupInformation diff --git a/tests/Test-DbaBuild.Tests.ps1 b/tests/Test-DbaBuild.Tests.ps1 index 42af41df9f..1e3e9c047f 100644 --- a/tests/Test-DbaBuild.Tests.ps1 +++ b/tests/Test-DbaBuild.Tests.ps1 @@ -4,22 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 9 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaBuild).Parameters.Keys - $knownParameters = 'Build', 'MinimumBuild', 'MaxBehind', 'Latest', 'SqlInstance', 'SqlCredential', 'Update', 'Quiet', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Build','MinimumBuild','MaxBehind','Latest','SqlInstance','SqlCredential','Update','Quiet','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaCmConnection.Tests.ps1 b/tests/Test-DbaCmConnection.Tests.ps1 index 0d35ba8495..1f71ebdd9b 100644 --- a/tests/Test-DbaCmConnection.Tests.ps1 +++ b/tests/Test-DbaCmConnection.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaCmConnection).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Type', 'Force', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Type','Force','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaConnection.Tests.ps1 b/tests/Test-DbaConnection.Tests.ps1 index 47d8fa4660..ed8f47504a 100644 --- a/tests/Test-DbaConnection.Tests.ps1 +++ b/tests/Test-DbaConnection.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaConnection).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaConnectionAuthScheme.Tests.ps1 b/tests/Test-DbaConnectionAuthScheme.Tests.ps1 index 48a13f679d..99ab15fb90 100644 --- a/tests/Test-DbaConnectionAuthScheme.Tests.ps1 +++ b/tests/Test-DbaConnectionAuthScheme.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaConnectionAuthScheme).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Kerberos', 'Ntlm', 'Detailed', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Kerberos','Ntlm','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDbCollation.Tests.ps1 b/tests/Test-DbaDbCollation.Tests.ps1 index eb1524d974..68cc6be4a2 100644 --- a/tests/Test-DbaDbCollation.Tests.ps1 +++ b/tests/Test-DbaDbCollation.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDbCollation).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Detailed', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDbCompatibility.Tests.ps1 b/tests/Test-DbaDbCompatibility.Tests.ps1 index 0cf5b2bdad..f7269215e3 100644 --- a/tests/Test-DbaDbCompatibility.Tests.ps1 +++ b/tests/Test-DbaDbCompatibility.Tests.ps1 @@ -4,22 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDbCompatibility).Parameters.Keys - $knownParameters = 'SqlInstance', 'Credential', 'Database', 'ExcludeDatabase', 'Detailed', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Credential','Database','ExcludeDatabase','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDbCompression.Tests.ps1 b/tests/Test-DbaDbCompression.Tests.ps1 index b73e784098..8a4fce5231 100644 --- a/tests/Test-DbaDbCompression.Tests.ps1 +++ b/tests/Test-DbaDbCompression.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 10 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDbCompression).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Schema', 'Table', 'ResultSize', 'Rank', 'FilterBy', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Schema','Table','ResultSize','Rank','FilterBy','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDbLogShipStatus.Tests.ps1 b/tests/Test-DbaDbLogShipStatus.Tests.ps1 index c8a66a0aeb..3a23a18ee4 100644 --- a/tests/Test-DbaDbLogShipStatus.Tests.ps1 +++ b/tests/Test-DbaDbLogShipStatus.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Simple', 'Primary', 'Secondary', 'EnableException' - $SupportShouldProcess = $false - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Simple','Primary','Secondary','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDbOwner.Tests.ps1 b/tests/Test-DbaDbOwner.Tests.ps1 index 24f4f40489..f089b2ea03 100644 --- a/tests/Test-DbaDbOwner.Tests.ps1 +++ b/tests/Test-DbaDbOwner.Tests.ps1 @@ -4,18 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDbOwner).Parameters.Keys - $knownParameters = 'InputObject', 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'TargetLogin', 'EnableException', 'Detailed' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $knownParameters.Count + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','TargetLogin','Detailed','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } InModuleScope 'dbatools' { diff --git a/tests/Test-DbaDbRecoveryModel.Tests.ps1 b/tests/Test-DbaDbRecoveryModel.Tests.ps1 index e30775191c..9c046b7a0e 100644 --- a/tests/Test-DbaDbRecoveryModel.Tests.ps1 +++ b/tests/Test-DbaDbRecoveryModel.Tests.ps1 @@ -4,22 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDbRecoveryModel).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'RecoveryModel', 'Database', 'ExcludeDatabase', 'EnableException', 'Detailed' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Database','ExcludeDatabase','SqlCredential','RecoveryModel','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDbVirtualLogFile.Tests.ps1 b/tests/Test-DbaDbVirtualLogFile.Tests.ps1 index e190b377f1..c78712104e 100644 --- a/tests/Test-DbaDbVirtualLogFile.Tests.ps1 +++ b/tests/Test-DbaDbVirtualLogFile.Tests.ps1 @@ -7,22 +7,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDbVirtualLogFile).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'IncludeSystemDbs', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','IncludeSystemDBs','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDeprecatedFeature.Tests.ps1 b/tests/Test-DbaDeprecatedFeature.Tests.ps1 index 405c9299fc..2948c37bc9 100644 --- a/tests/Test-DbaDeprecatedFeature.Tests.ps1 +++ b/tests/Test-DbaDeprecatedFeature.Tests.ps1 @@ -5,22 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDeprecatedFeature).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDiskAlignment.Tests.ps1 b/tests/Test-DbaDiskAlignment.Tests.ps1 index df81a18066..1f79b1862e 100644 --- a/tests/Test-DbaDiskAlignment.Tests.ps1 +++ b/tests/Test-DbaDiskAlignment.Tests.ps1 @@ -4,22 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDiskAlignment).Parameters.Keys - $knownParameters = 'ComputerName', 'SqlCredential', 'Credential', 'NoSqlCheck', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','SqlCredential','NoSqlCheck','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Test-DbaDiskAllocation.Tests.ps1 b/tests/Test-DbaDiskAllocation.Tests.ps1 index ff356ac4f9..6cd02f99fe 100644 --- a/tests/Test-DbaDiskAllocation.Tests.ps1 +++ b/tests/Test-DbaDiskAllocation.Tests.ps1 @@ -4,22 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 6 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Test-DbaDiskAllocation).Parameters.Keys - $knownParameters = 'ComputerName', 'NoSqlCheck', 'SqlCredential', 'Credential', 'Detailed', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','NoSqlCheck','SqlCredential','Credential','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaDiskSpeed.Tests.ps1 b/tests/Test-DbaDiskSpeed.Tests.ps1 index b539c2f03b..144f639a35 100644 --- a/tests/Test-DbaDiskSpeed.Tests.ps1 +++ b/tests/Test-DbaDiskSpeed.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaDiskSpeed).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaEndpoint.Tests.ps1 b/tests/Test-DbaEndpoint.Tests.ps1 index bd7114b8ef..d307c9fa80 100644 --- a/tests/Test-DbaEndpoint.Tests.ps1 +++ b/tests/Test-DbaEndpoint.Tests.ps1 @@ -4,23 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tags "UnitTests" { Context "Validate parameters" { - $knownParameters = 'SqlInstance', 'SqlCredential', 'Endpoint', 'InputObject', 'EnableException' - $SupportShouldProcess = $false - $paramCount = $knownParameters.Count - if ($SupportShouldProcess) { - $defaultParamCount = 13 - } else { - $defaultParamCount = 11 - } - $command = Get-Command -Name $CommandName - [object[]]$params = $command.Parameters.Keys - - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Endpoint','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaIdentityUsage.Tests.ps1 b/tests/Test-DbaIdentityUsage.Tests.ps1 index b01e0fdcb5..a66f4a0e38 100644 --- a/tests/Test-DbaIdentityUsage.Tests.ps1 +++ b/tests/Test-DbaIdentityUsage.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaIdentityUsage).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Threshold', 'ExcludeSystem', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Threshold','ExcludeSystem','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaLastBackup.Tests.ps1 b/tests/Test-DbaLastBackup.Tests.ps1 index e04472e8cc..ffcef13263 100644 --- a/tests/Test-DbaLastBackup.Tests.ps1 +++ b/tests/Test-DbaLastBackup.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Test-DbaLastBackup).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'ExcludeDatabase', 'Destination', 'DestinationCredential', 'DataDirectory', 'LogDirectory', 'Prefix', 'VerifyOnly', 'NoCheck', 'NoDrop', 'CopyFile', 'CopyPath', 'MaxSize', 'IncludeCopyOnly', 'IgnoreLogBackup', 'AzureCredential', 'InputObject', 'EnableException' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','ExcludeDatabase','Destination','DestinationCredential','DataDirectory','LogDirectory','Prefix','VerifyOnly','NoCheck','NoDrop','CopyFile','CopyPath','MaxSize','IncludeCopyOnly','IgnoreLogBackup','AzureCredential','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaLinkedServerConnection.Tests.ps1 b/tests/Test-DbaLinkedServerConnection.Tests.ps1 index 732c70bc0d..2e3e8bbc1a 100644 --- a/tests/Test-DbaLinkedServerConnection.Tests.ps1 +++ b/tests/Test-DbaLinkedServerConnection.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaLinkedServerConnection).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaLoginPassword.Tests.ps1 b/tests/Test-DbaLoginPassword.Tests.ps1 index e77be13c92..0b6849c2b6 100644 --- a/tests/Test-DbaLoginPassword.Tests.ps1 +++ b/tests/Test-DbaLoginPassword.Tests.ps1 @@ -5,15 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag UnitTests, Get-DbaLogin { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaLoginPassword).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Dictionary', 'Login', 'InputObject', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','Dictionary','InputObject','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaLsnChain.Tests.ps1 b/tests/Test-DbaLsnChain.Tests.ps1 index 0a95c4ddb1..0de723c779 100644 --- a/tests/Test-DbaLsnChain.Tests.ps1 +++ b/tests/Test-DbaLsnChain.Tests.ps1 @@ -1,8 +1,20 @@ $CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" +. "$PSScriptRoot\..\internal\functions\Test-DbaLsnChain.ps1" Describe "$commandname Unit Tests" -Tag 'UnitTests' { + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'FilteredRestoreFiles','Continue','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} + +Describe "$commandname Integration Tests" -Tag 'IntegrationTests' { InModuleScope dbatools { Context "General Diff restore" { $Header = ConvertFrom-Json -InputObject (Get-Content $PSScriptRoot\..\tests\ObjectDefinitions\BackupRestore\RawInput\DiffRestore.json -raw) diff --git a/tests/Test-DbaManagementObject.Tests.ps1 b/tests/Test-DbaManagementObject.Tests.ps1 index 52e382ae81..371c2bfb4d 100644 --- a/tests/Test-DbaManagementObject.Tests.ps1 +++ b/tests/Test-DbaManagementObject.Tests.ps1 @@ -10,22 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem Function:\Test-DbaManagementObject).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'VersionNumber', 'EnableException' - it "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','VersionNumber','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaMaxDop.Tests.ps1 b/tests/Test-DbaMaxDop.Tests.ps1 index bd9f6baa03..28f9973e1f 100644 --- a/tests/Test-DbaMaxDop.Tests.ps1 +++ b/tests/Test-DbaMaxDop.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaMaxDop).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Detailed', 'EnableException' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaMaxMemory.Tests.ps1 b/tests/Test-DbaMaxMemory.Tests.ps1 index b06228f274..b204637a50 100644 --- a/tests/Test-DbaMaxMemory.Tests.ps1 +++ b/tests/Test-DbaMaxMemory.Tests.ps1 @@ -3,10 +3,12 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" Describe "$commandname Integration Tests" -Tags "IntegrationTests" { - Context "Connects to multiple instances" { - It 'Returns multiple objects' { - $results = Test-DbaMaxMemory -SqlInstance $script:instance1, $script:instance2 - $results.Count | Should BeGreaterThan 1 # and ultimately not throw an exception + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaMigrationConstraint.Tests.ps1 b/tests/Test-DbaMigrationConstraint.Tests.ps1 index 3cbb0c2a78..558c8bb380 100644 --- a/tests/Test-DbaMigrationConstraint.Tests.ps1 +++ b/tests/Test-DbaMigrationConstraint.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaMigrationConstraint).Parameters.Keys - $knownParameters = 'Source', 'SourceSqlCredential', 'Destination', 'DestinationSqlCredential', 'Database', 'ExcludeDatabase', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Source','SourceSqlCredential','Destination','DestinationSqlCredential','Database','ExcludeDatabase','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaNetworkLatency.Tests.ps1 b/tests/Test-DbaNetworkLatency.Tests.ps1 index b0bced783b..905f66787a 100644 --- a/tests/Test-DbaNetworkLatency.Tests.ps1 +++ b/tests/Test-DbaNetworkLatency.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaNetworkLatency).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Query', 'Count', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Query','Count','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaOptimizeForAdHoc.Tests.ps1 b/tests/Test-DbaOptimizeForAdHoc.Tests.ps1 index f0d51d78ba..f146908006 100644 --- a/tests/Test-DbaOptimizeForAdHoc.Tests.ps1 +++ b/tests/Test-DbaOptimizeForAdHoc.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaOptimizeForAdHoc).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaPath.Tests.ps1 b/tests/Test-DbaPath.Tests.ps1 index 5d38f65f5d..6398323d3d 100644 --- a/tests/Test-DbaPath.Tests.ps1 +++ b/tests/Test-DbaPath.Tests.ps1 @@ -10,22 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaPath).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Path', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Path','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaPowerPlan.Tests.ps1 b/tests/Test-DbaPowerPlan.Tests.ps1 index 4fa9ff3377..bf4c81f94c 100644 --- a/tests/Test-DbaPowerPlan.Tests.ps1 +++ b/tests/Test-DbaPowerPlan.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaPowerPlan).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'CustomPowerPlan', 'Detailed', 'EnableException', 'InputObject' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','CustomPowerPlan','InputObject','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaRepLatency.Tests.ps1 b/tests/Test-DbaRepLatency.Tests.ps1 index 5da90305af..602e2c2808 100644 --- a/tests/Test-DbaRepLatency.Tests.ps1 +++ b/tests/Test-DbaRepLatency.Tests.ps1 @@ -4,24 +4,12 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan . "$PSScriptRoot\..\internal\functions\Connect-SqlInstance.ps1" Describe "$commandname Unit Tests" -Tag 'UnitTests' { - - InModuleScope dbatools { - - Context "Parameter Validation" { - - [object[]]$params = (Get-ChildItem function:\Test-DbaRepLatency).Parameters.Keys - $knownParameters = 'SqlInstance', 'Database', 'SqlCredential', 'PublicationName', 'TimeToLive', 'RetainToken', 'DisplayTokenHistory', 'EnableException' - $paramCount = $knownParameters.Count - $defaultParamCount = $params.Count - $paramCount - - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount - } - + Context "Validate parameters" { + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Database','SqlCredential','PublicationName','TimeToLive','RetainToken','DisplayTokenHistory','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } \ No newline at end of file diff --git a/tests/Test-DbaServerName.Tests.ps1 b/tests/Test-DbaServerName.Tests.ps1 index f2166f7e5d..2d94f8722b 100644 --- a/tests/Test-DbaServerName.Tests.ps1 +++ b/tests/Test-DbaServerName.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 5 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaServerName).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Detailed', 'ExcludeSsrs', 'EnableException' - it "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Detailed','ExcludeSsrs','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaSpn.Tests.ps1 b/tests/Test-DbaSpn.Tests.ps1 index 9964479a93..4beef3119a 100644 --- a/tests/Test-DbaSpn.Tests.ps1 +++ b/tests/Test-DbaSpn.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 3 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaSpn).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaTempDbConfig.Tests.ps1 b/tests/Test-DbaTempDbConfig.Tests.ps1 index 483af9ba2c..6a10e467e1 100644 --- a/tests/Test-DbaTempDbConfig.Tests.ps1 +++ b/tests/Test-DbaTempDbConfig.Tests.ps1 @@ -10,22 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 4 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaTempdbConfig).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException', 'Detailed' - It "Should contain our specific parameters" { - ((Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-DbaWindowsLogin.Tests.ps1 b/tests/Test-DbaWindowsLogin.Tests.ps1 index 09c6c1eaeb..4203c19209 100644 --- a/tests/Test-DbaWindowsLogin.Tests.ps1 +++ b/tests/Test-DbaWindowsLogin.Tests.ps1 @@ -10,22 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 8 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-DbaWindowsLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Login', 'ExcludeLogin', 'FilterBy', 'IgnoreDomains', 'EnableException', 'Detailed' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Login','ExcludeLogin','FilterBy','IgnoreDomains','Detailed','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Test-PSRemoting.Tests.ps1 b/tests/Test-PSRemoting.Tests.ps1 index d7fe713870..9c06883acc 100644 --- a/tests/Test-PSRemoting.Tests.ps1 +++ b/tests/Test-PSRemoting.Tests.ps1 @@ -1,22 +1,16 @@ $CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan . "$PSScriptRoot\constants.ps1" +. "$PSScriptRoot\..\internal\functions\Test-PSRemoting.ps1" + Describe "$CommandName Unit Tests" -Tag "UnitTests" { Context "Validate parameters" { - $paramCount = 3 - <# - Get commands, Default count = 11 - Commands with SupportShouldProcess = 13 - #> - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Test-PSRemoting).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'EnableException' - It "Contains our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Contains $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName', 'Credential', 'EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Uninstall-DbaSqlWatch.Tests.ps1 b/tests/Uninstall-DbaSqlWatch.Tests.ps1 index 8ace60b9e0..9e768cebc5 100644 --- a/tests/Uninstall-DbaSqlWatch.Tests.ps1 +++ b/tests/Uninstall-DbaSqlWatch.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 4 - $commonParamCount = ([System.Management.Automation.PSCmdlet]::CommonParameters).Count + 2 - [object[]]$params = (Get-ChildItem function:\Uninstall-DbaSqlWatch).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $commonParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Uninstall-DbaWatchUpdate.Tests.ps1 b/tests/Uninstall-DbaWatchUpdate.Tests.ps1 index 52d62719de..d3f33db929 100644 --- a/tests/Uninstall-DbaWatchUpdate.Tests.ps1 +++ b/tests/Uninstall-DbaWatchUpdate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 0 - $defaultParamCount = 0 - [object[]]$params = (Get-ChildItem function:\Uninstall-DbaWatchUpdate).Parameters.Keys - $knownParameters = '' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = $null + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It -Skip "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Update-DbaInstance.Tests.ps1 b/tests/Update-DbaInstance.Tests.ps1 index 61d055c50b..87f00779d2 100644 --- a/tests/Update-DbaInstance.Tests.ps1 +++ b/tests/Update-DbaInstance.Tests.ps1 @@ -20,15 +20,11 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Mock -CommandName Get-DbaDiskSpace -MockWith { [pscustomobject]@{ Name = 'C:\'; Free = 1 } } -ModuleName dbatools } Context "Validate parameters" { - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\$CommandName).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'Version', 'Type', 'Path', 'Restart', 'EnableException', 'Kb', 'InstanceName', 'Continue', 'Throttle', 'Authentication' - $paramCount = $knownParameters.Count - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','Version','Type','KB','InstanceName','Path','Restart','Continue','Throttle','Authentication','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } Context "Validate upgrades to a latest version" { diff --git a/tests/Update-DbaServiceAccount.Tests.ps1 b/tests/Update-DbaServiceAccount.Tests.ps1 index 0c9c7b11be..9f967bc3c5 100644 --- a/tests/Update-DbaServiceAccount.Tests.ps1 +++ b/tests/Update-DbaServiceAccount.Tests.ps1 @@ -5,15 +5,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 9 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Update-DbaServiceAccount).Parameters.Keys - $knownParameters = 'ComputerName', 'Credential', 'InputObject', 'ServiceName', 'Username', 'ServiceCredential', 'PreviousPassword', 'SecurePassword', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'ComputerName','Credential','InputObject','ServiceName','Username','ServiceCredential','PreviousPassword','SecurePassword','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Update-dbatools.Tests.ps1 b/tests/Update-dbatools.Tests.ps1 index 83e0f22e71..d25eaf1ff5 100644 --- a/tests/Update-dbatools.Tests.ps1 +++ b/tests/Update-dbatools.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 2 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Update-dbatools).Parameters.Keys - $knownParameters = 'Development', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'Development', 'EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Watch-DbaDbLogin.Tests.ps1 b/tests/Watch-DbaDbLogin.Tests.ps1 index 7e84872b52..6682f5a728 100644 --- a/tests/Watch-DbaDbLogin.Tests.ps1 +++ b/tests/Watch-DbaDbLogin.Tests.ps1 @@ -10,22 +10,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan #> Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - <# - The $paramCount is adjusted based on the parameters your command will have. - - The $defaultParamCount is adjusted based on what type of command you are writing the test for: - - Commands that *do not* include SupportShouldProcess, set defaultParamCount = 11 - - Commands that *do* include SupportShouldProcess, set defaultParamCount = 13 - #> - $paramCount = 7 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Watch-DbaDbLogin).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'EnableException', 'Database', 'Table', 'SqlCms', 'ServersFromFile' - it "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - it "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','Database','Table','SqlCredential','SqlCms','ServersFromFile','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Watch-DbaUpdate.Tests.ps1 b/tests/Watch-DbaUpdate.Tests.ps1 index d932657613..9fb0f83897 100644 --- a/tests/Watch-DbaUpdate.Tests.ps1 +++ b/tests/Watch-DbaUpdate.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 0 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Watch-DbaUpdate).Parameters.Keys - $knownParameters = '' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = '' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Watch-DbaXESession.Tests.ps1 b/tests/Watch-DbaXESession.Tests.ps1 index 05ede355cf..5fe45411aa 100644 --- a/tests/Watch-DbaXESession.Tests.ps1 +++ b/tests/Watch-DbaXESession.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 6 - $defaultParamCount = 11 - [object[]]$params = (Get-ChildItem function:\Watch-DbaXESession).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Session', 'InputObject', 'Raw', 'EnableException' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Session','InputObject','Raw','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } } diff --git a/tests/Write-DbaDataTable.Tests.ps1 b/tests/Write-DbaDataTable.Tests.ps1 index c8ac05f9f3..a99c951b23 100644 --- a/tests/Write-DbaDataTable.Tests.ps1 +++ b/tests/Write-DbaDataTable.Tests.ps1 @@ -4,15 +4,11 @@ Write-Host -Object "Running $PSCommandPath" -ForegroundColor Cyan Describe "$CommandName Unit Tests" -Tag 'UnitTests' { Context "Validate parameters" { - $paramCount = 19 - $defaultParamCount = 13 - [object[]]$params = (Get-ChildItem function:\Write-DbaDataTable).Parameters.Keys - $knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'InputObject', 'Table', 'Schema', 'BatchSize', 'NotifyAfter', 'AutoCreateTable', 'NoTableLock', 'CheckConstraints', 'FireTriggers', 'KeepIdentity', 'KeepNulls', 'Truncate', 'bulkCopyTimeOut', 'RegularUser', 'EnableException', 'UseDynamicStringLength' - It "Should contain our specific parameters" { - ( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount - } - It "Should only contain $paramCount parameters" { - $params.Count - $defaultParamCount | Should Be $paramCount + [object[]]$params = (Get-Command $CommandName).Parameters.Keys | Where-Object {$_ -notin ('whatif', 'confirm')} + [object[]]$knownParameters = 'SqlInstance','SqlCredential','Database','InputObject','Table','Schema','BatchSize','NotifyAfter','AutoCreateTable','NoTableLock','CheckConstraints','FireTriggers','KeepIdentity','KeepNulls','Truncate','bulkCopyTimeOut','RegularUser','EnableException','UseDynamicStringLength' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 } } }