diff --git a/.aider/aider.psm1 b/.aider/aider.psm1 index 1008a150e9..9e9a821365 100644 --- a/.aider/aider.psm1 +++ b/.aider/aider.psm1 @@ -284,7 +284,9 @@ function Repair-Error { $allObjects = @() $prompts = @{ - ReorgParamTest = "Move the `$expected` parameter list into the 'Should have exactly the number of expected parameters' It block, keeping it between the It block declaration and the `$hasparms` assignment. Do not move the initial `$command` assignment." + ReorgParamTest = "Move the `$expected` parameter list AND the `$TestConfig.CommonParameters part into the 'Should have exactly the number of expected parameters' It block, keeping it between the It block declaration and the `$hasparms` assignment. Do not move the initial `$command` assignment. + + If you can't find the `$expected` parameter list, do not make any changes." } Write-Verbose "Available prompt types: $($prompts.Keys -join ', ')" @@ -321,6 +323,11 @@ function Repair-Error { end { Write-Verbose "Starting end block processing" + if ($InputObject.Count -eq 0) { + Write-Verbose "No input objects provided, getting commands from dbatools module" + $allObjects += Get-Command -Module dbatools -Type Function, Cmdlet | Select-Object -First $First -Skip $Skip + } + if (-not $PromptFilePath -and -not $Type) { Write-Verbose "Neither PromptFilePath nor Type specified" throw "You must specify either PromptFilePath or Type" diff --git a/tests/Add-DbaAgListener.Tests.ps1 b/tests/Add-DbaAgListener.Tests.ps1 index d35a3e925e..a5e3c7dce2 100644 --- a/tests/Add-DbaAgListener.Tests.ps1 +++ b/tests/Add-DbaAgListener.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaAgListener" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaAgListener - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -24,13 +30,6 @@ Describe "Add-DbaAgListener" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaAgReplica.Tests.ps1 b/tests/Add-DbaAgReplica.Tests.ps1 index 2dced103eb..d2d4dbf313 100644 --- a/tests/Add-DbaAgReplica.Tests.ps1 +++ b/tests/Add-DbaAgReplica.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaAgReplica" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaAgReplica - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -32,13 +38,6 @@ Describe "Add-DbaAgReplica" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaComputerCertificate.Tests.ps1 b/tests/Add-DbaComputerCertificate.Tests.ps1 index c6753f1c6f..682b2092f8 100644 --- a/tests/Add-DbaComputerCertificate.Tests.ps1 +++ b/tests/Add-DbaComputerCertificate.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaComputerCertificate" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaComputerCertificate - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "ComputerName", "Credential", @@ -21,13 +27,6 @@ Describe "Add-DbaComputerCertificate" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaDbMirrorMonitor.Tests.ps1 b/tests/Add-DbaDbMirrorMonitor.Tests.ps1 index e10a4ec812..e9d0823d5e 100644 --- a/tests/Add-DbaDbMirrorMonitor.Tests.ps1 +++ b/tests/Add-DbaDbMirrorMonitor.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaDbMirrorMonitor" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaDbMirrorMonitor - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -15,13 +21,6 @@ Describe "Add-DbaDbMirrorMonitor" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaDbRoleMember.Tests.ps1 b/tests/Add-DbaDbRoleMember.Tests.ps1 index 493f027c3e..b522c2df5e 100644 --- a/tests/Add-DbaDbRoleMember.Tests.ps1 +++ b/tests/Add-DbaDbRoleMember.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaDbRoleMember" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaDbRoleMember - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -19,13 +25,6 @@ Describe "Add-DbaDbRoleMember" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaExtendedProperty.Tests.ps1 b/tests/Add-DbaExtendedProperty.Tests.ps1 index 8694a1dc58..db26f643a9 100644 --- a/tests/Add-DbaExtendedProperty.Tests.ps1 +++ b/tests/Add-DbaExtendedProperty.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaExtendedProperty" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaExtendedProperty - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -19,13 +25,6 @@ Describe "Add-DbaExtendedProperty" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 b/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 index 641a10d9c5..83216196e7 100644 --- a/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 +++ b/tests/Add-DbaPfDataCollectorCounter.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaPfDataCollectorCounter" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaPfDataCollectorCounter - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "ComputerName", "Credential", @@ -19,13 +25,6 @@ Describe "Add-DbaPfDataCollectorCounter" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaRegServer.Tests.ps1 b/tests/Add-DbaRegServer.Tests.ps1 index 6c30c765ad..7120138bb1 100644 --- a/tests/Add-DbaRegServer.Tests.ps1 +++ b/tests/Add-DbaRegServer.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaRegServer" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaRegServer - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -25,13 +31,6 @@ Describe "Add-DbaRegServer" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaRegServerGroup.Tests.ps1 b/tests/Add-DbaRegServerGroup.Tests.ps1 index 0d653f71d5..5a5d900ee2 100644 --- a/tests/Add-DbaRegServerGroup.Tests.ps1 +++ b/tests/Add-DbaRegServerGroup.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaRegServerGroup" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaRegServerGroup - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -19,13 +25,6 @@ Describe "Add-DbaRegServerGroup" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaReplArticle.Tests.ps1 b/tests/Add-DbaReplArticle.Tests.ps1 index e9f043bbca..670970ab5d 100644 --- a/tests/Add-DbaReplArticle.Tests.ps1 +++ b/tests/Add-DbaReplArticle.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaReplArticle" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaReplArticle - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -21,13 +27,6 @@ Describe "Add-DbaReplArticle" -Tag "UnitTests" { "WhatIf", "Confirm" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Add-DbaServerRoleMember.Tests.ps1 b/tests/Add-DbaServerRoleMember.Tests.ps1 index 926ced05a0..1f54be7306 100644 --- a/tests/Add-DbaServerRoleMember.Tests.ps1 +++ b/tests/Add-DbaServerRoleMember.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Add-DbaServerRoleMember" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Add-DbaServerRoleMember - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -19,13 +25,6 @@ Describe "Add-DbaServerRoleMember" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Backup-DbaComputerCertificate.Tests.ps1 b/tests/Backup-DbaComputerCertificate.Tests.ps1 index 729ce0451f..8ecd850d05 100644 --- a/tests/Backup-DbaComputerCertificate.Tests.ps1 +++ b/tests/Backup-DbaComputerCertificate.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Backup-DbaComputerCertificate" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Backup-DbaComputerCertificate - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SecurePassword", "InputObject", @@ -18,13 +24,6 @@ Describe "Backup-DbaComputerCertificate" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Backup-DbaDbCertificate.Tests.ps1 b/tests/Backup-DbaDbCertificate.Tests.ps1 index c4960b11bd..acd48ddc6a 100644 --- a/tests/Backup-DbaDbCertificate.Tests.ps1 +++ b/tests/Backup-DbaDbCertificate.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Backup-DbaDbCertificate" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Backup-DbaDbCertificate - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -23,13 +29,6 @@ Describe "Backup-DbaDbCertificate" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Backup-DbaDbMasterKey.Tests.ps1 b/tests/Backup-DbaDbMasterKey.Tests.ps1 index 238851e8fd..0eeff76ea2 100644 --- a/tests/Backup-DbaDbMasterKey.Tests.ps1 +++ b/tests/Backup-DbaDbMasterKey.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Backup-DbaDbMasterKey" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Backup-DbaDbMasterKey - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -21,13 +27,6 @@ Describe "Backup-DbaDbMasterKey" -Tag "UnitTests" { "WhatIf", "Confirm" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Backup-DbaServiceMasterKey.Tests.ps1 b/tests/Backup-DbaServiceMasterKey.Tests.ps1 index 120207f18b..983e2be3f9 100644 --- a/tests/Backup-DbaServiceMasterKey.Tests.ps1 +++ b/tests/Backup-DbaServiceMasterKey.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Backup-DbaServiceMasterKey" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Backup-DbaServiceMasterKey - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -18,13 +24,6 @@ Describe "Backup-DbaServiceMasterKey" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Clear-DbaConnectionPool.Tests.ps1 b/tests/Clear-DbaConnectionPool.Tests.ps1 index 121c591f56..9b949326b9 100644 --- a/tests/Clear-DbaConnectionPool.Tests.ps1 +++ b/tests/Clear-DbaConnectionPool.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Clear-DbaConnectionPool" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Clear-DbaConnectionPool - $expected = $TestConfig.CommonParameters + } + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "ComputerName", "Credential", @@ -15,13 +21,7 @@ Describe "Clear-DbaConnectionPool" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Clear-DbaLatchStatistics.Tests.ps1 b/tests/Clear-DbaLatchStatistics.Tests.ps1 index 0de6622239..eb471780be 100644 --- a/tests/Clear-DbaLatchStatistics.Tests.ps1 +++ b/tests/Clear-DbaLatchStatistics.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Clear-DbaLatchStatistics" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Clear-DbaLatchStatistics - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -15,13 +21,6 @@ Describe "Clear-DbaLatchStatistics" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Clear-DbaPlanCache.Tests.ps1 b/tests/Clear-DbaPlanCache.Tests.ps1 index a7b3d2df1b..375b742f68 100644 --- a/tests/Clear-DbaPlanCache.Tests.ps1 +++ b/tests/Clear-DbaPlanCache.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Clear-DbaPlanCache" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Clear-DbaPlanCache - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -17,13 +23,6 @@ Describe "Clear-DbaPlanCache" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Clear-DbaWaitStatistics.Tests.ps1 b/tests/Clear-DbaWaitStatistics.Tests.ps1 index 8e460bfb4e..c821740710 100644 --- a/tests/Clear-DbaWaitStatistics.Tests.ps1 +++ b/tests/Clear-DbaWaitStatistics.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Clear-DbaWaitStatistics" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Clear-DbaWaitStatistics - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "SqlInstance", "SqlCredential", @@ -15,13 +21,6 @@ Describe "Clear-DbaWaitStatistics" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Convert-DbaLsn.Tests.ps1 b/tests/Convert-DbaLsn.Tests.ps1 index c6c17c8d3b..5a8ffe593e 100644 --- a/tests/Convert-DbaLsn.Tests.ps1 +++ b/tests/Convert-DbaLsn.Tests.ps1 @@ -6,14 +6,6 @@ Describe "Convert-DbaLSN" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Convert-DbaLSN - $expected = $TestConfig.CommonParameters - - $expected += @( - "LSN", - "EnableException", - "Confirm", - "WhatIf" - ) } It "Has parameter: <_>" -ForEach $expected { @@ -21,6 +13,13 @@ Describe "Convert-DbaLSN" -Tag "UnitTests" { } It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters + $expected += @( + "LSN", + "EnableException", + "Confirm", + "WhatIf" + ) $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Convert-DbaMaskingValue.Tests.ps1 b/tests/Convert-DbaMaskingValue.Tests.ps1 index f7649f7f73..408d68c52d 100644 --- a/tests/Convert-DbaMaskingValue.Tests.ps1 +++ b/tests/Convert-DbaMaskingValue.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Convert-DbaMaskingValue" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Convert-DbaMaskingValue - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "Value", "DataType", @@ -16,13 +22,6 @@ Describe "Convert-DbaMaskingValue" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/ConvertTo-DbaTimeline.Tests.ps1 b/tests/ConvertTo-DbaTimeline.Tests.ps1 index a20c74d9da..64684c21f5 100644 --- a/tests/ConvertTo-DbaTimeline.Tests.ps1 +++ b/tests/ConvertTo-DbaTimeline.Tests.ps1 @@ -6,13 +6,6 @@ Describe "ConvertTo-DbaTimeline" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command ConvertTo-DbaTimeline - $expected = $TestConfig.CommonParameters - - $expected += @( - "InputObject", - "ExcludeRowLabel", - "EnableException" - ) } It "Has parameter: <_>" -ForEach $expected { @@ -20,6 +13,12 @@ Describe "ConvertTo-DbaTimeline" -Tag "UnitTests" { } It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters + $expected += @( + "InputObject", + "ExcludeRowLabel", + "EnableException" + ) $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/ConvertTo-DbaXESession.Tests.ps1 b/tests/ConvertTo-DbaXESession.Tests.ps1 index 312130190a..6cdd6f4b0b 100644 --- a/tests/ConvertTo-DbaXESession.Tests.ps1 +++ b/tests/ConvertTo-DbaXESession.Tests.ps1 @@ -6,8 +6,14 @@ Describe "ConvertTo-DbaXESession" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command ConvertTo-DbaXESession - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "InputObject", "Name", @@ -16,13 +22,6 @@ Describe "ConvertTo-DbaXESession" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Copy-DbaAgentAlert.Tests.ps1 b/tests/Copy-DbaAgentAlert.Tests.ps1 index 95d3af3df5..7e53a32de1 100644 --- a/tests/Copy-DbaAgentAlert.Tests.ps1 +++ b/tests/Copy-DbaAgentAlert.Tests.ps1 @@ -6,8 +6,14 @@ Describe "Copy-DbaAgentAlert" -Tag "UnitTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Copy-DbaAgentAlert - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "Source", "SourceSqlCredential", @@ -21,13 +27,6 @@ Describe "Copy-DbaAgentAlert" -Tag "UnitTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Copy-DbaAgentJob.Tests.ps1 b/tests/Copy-DbaAgentJob.Tests.ps1 index 5a385f42f5..532f9e07af 100644 --- a/tests/Copy-DbaAgentJob.Tests.ps1 +++ b/tests/Copy-DbaAgentJob.Tests.ps1 @@ -17,8 +17,14 @@ Describe "Copy-DbaAgentJob" -Tag "IntegrationTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Copy-DbaAgentJob - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "Source", "SourceSqlCredential", @@ -34,13 +40,6 @@ Describe "Copy-DbaAgentJob" -Tag "IntegrationTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty } diff --git a/tests/Copy-DbaAgentJobCategory.Tests.ps1 b/tests/Copy-DbaAgentJobCategory.Tests.ps1 index e65f1f4daf..3705d60d90 100644 --- a/tests/Copy-DbaAgentJobCategory.Tests.ps1 +++ b/tests/Copy-DbaAgentJobCategory.Tests.ps1 @@ -13,8 +13,14 @@ Describe "Copy-DbaAgentJobCategory" -Tag "IntegrationTests" { Context "Parameter validation" { BeforeAll { $command = Get-Command Copy-DbaAgentJobCategory - $expected = $TestConfig.CommonParameters + } + + It "Has parameter: <_>" -ForEach $expected { + $command | Should -HaveParameter $PSItem + } + It "Should have exactly the number of expected parameters" { + $expected = $TestConfig.CommonParameters $expected += @( "Source", "SourceSqlCredential", @@ -29,13 +35,6 @@ Describe "Copy-DbaAgentJobCategory" -Tag "IntegrationTests" { "Confirm", "WhatIf" ) - } - - It "Has parameter: <_>" -ForEach $expected { - $command | Should -HaveParameter $PSItem - } - - It "Should have exactly the number of expected parameters" { $hasparms = $command.Parameters.Values.Name Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty }