From 811cfaf9fba4d922c08649a0cbec253fc8ffd002 Mon Sep 17 00:00:00 2001 From: jpomfret Date: Sun, 20 Jan 2019 08:37:07 -0500 Subject: [PATCH 1/2] add missing unit tests --- tests/Export-DbatoolsConfig.Tests.ps1 | 19 +++++++++++++++++++ tests/Import-DbatoolsConfig.Tests.ps1 | 19 +++++++++++++++++++ tests/Invoke-DbaAgFailover.Tests.ps1 | 19 +++++++++++++++++++ tests/Join-DbaAvailabilityGroup.Tests.ps1 | 19 +++++++++++++++++++ ...Remove-DbaDbBackupRestoreHistory.Tests.ps1 | 19 +++++++++++++++++++ tests/Reset-DbatoolsConfig.Tests.ps1 | 19 +++++++++++++++++++ tests/Set-DbaDbCompatibility.Tests.ps1 | 19 +++++++++++++++++++ tests/Sync-DbaAvailabilityGroup.Tests.ps1 | 19 +++++++++++++++++++ tests/Unregister-DbatoolsConfig.Tests.ps1 | 19 +++++++++++++++++++ 9 files changed, 171 insertions(+) create mode 100644 tests/Export-DbatoolsConfig.Tests.ps1 create mode 100644 tests/Import-DbatoolsConfig.Tests.ps1 create mode 100644 tests/Invoke-DbaAgFailover.Tests.ps1 create mode 100644 tests/Join-DbaAvailabilityGroup.Tests.ps1 create mode 100644 tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 create mode 100644 tests/Reset-DbatoolsConfig.Tests.ps1 create mode 100644 tests/Set-DbaDbCompatibility.Tests.ps1 create mode 100644 tests/Sync-DbaAvailabilityGroup.Tests.ps1 create mode 100644 tests/Unregister-DbatoolsConfig.Tests.ps1 diff --git a/tests/Export-DbatoolsConfig.Tests.ps1 b/tests/Export-DbatoolsConfig.Tests.ps1 new file mode 100644 index 0000000000..ce8056cb4e --- /dev/null +++ b/tests/Export-DbatoolsConfig.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'FullName', 'Module', 'Name', 'Config', 'ModuleName', 'ModuleVersion', 'Scope', 'OutPath', 'SkipUnchanged', 'EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Import-DbatoolsConfig.Tests.ps1 b/tests/Import-DbatoolsConfig.Tests.ps1 new file mode 100644 index 0000000000..f26ff4242d --- /dev/null +++ b/tests/Import-DbatoolsConfig.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'Path','ModuleName','ModuleVersion','Scope','IncludeFilter','ExcludeFilter','Peek','EnableException' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Invoke-DbaAgFailover.Tests.ps1 b/tests/Invoke-DbaAgFailover.Tests.ps1 new file mode 100644 index 0000000000..241805cc08 --- /dev/null +++ b/tests/Invoke-DbaAgFailover.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'SqlInstance','SqlCredential','AvailabilityGroup','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 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Join-DbaAvailabilityGroup.Tests.ps1 b/tests/Join-DbaAvailabilityGroup.Tests.ps1 new file mode 100644 index 0000000000..665f17093d --- /dev/null +++ b/tests/Join-DbaAvailabilityGroup.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'SqlInstance','SqlCredential','AvailabilityGroup','ClusterType','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 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 b/tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 new file mode 100644 index 0000000000..d5faa31959 --- /dev/null +++ b/tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'SqlInstance','SqlCredential','KeepDays','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 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Reset-DbatoolsConfig.Tests.ps1 b/tests/Reset-DbatoolsConfig.Tests.ps1 new file mode 100644 index 0000000000..9f07d0f4d3 --- /dev/null +++ b/tests/Reset-DbatoolsConfig.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'ConfigurationItem','FullName','Module','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 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Set-DbaDbCompatibility.Tests.ps1 b/tests/Set-DbaDbCompatibility.Tests.ps1 new file mode 100644 index 0000000000..b1b1cc1ecc --- /dev/null +++ b/tests/Set-DbaDbCompatibility.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'SqlInstance','SqlCredential','Database','TargetCompatibility','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 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Sync-DbaAvailabilityGroup.Tests.ps1 b/tests/Sync-DbaAvailabilityGroup.Tests.ps1 new file mode 100644 index 0000000000..f1bdde3ae0 --- /dev/null +++ b/tests/Sync-DbaAvailabilityGroup.Tests.ps1 @@ -0,0 +1,19 @@ +$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','Secondary','SecondarySqlCredential','AvailabilityGroup','Exclude','Login','ExcludeLogin','Job','ExcludeJob','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 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file diff --git a/tests/Unregister-DbatoolsConfig.Tests.ps1 b/tests/Unregister-DbatoolsConfig.Tests.ps1 new file mode 100644 index 0000000000..4b19db1a53 --- /dev/null +++ b/tests/Unregister-DbatoolsConfig.Tests.ps1 @@ -0,0 +1,19 @@ +$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 = 'ConfigurationItem','FullName','Module','Name','Scope' + $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters + It "Should only contain our specific parameters" { + (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0 + } + } +} +<# + Integration test are custom to the command you are writing for. + Read https://github.com/sqlcollaborative/dbatools/blob/development/contributing.md#tests + for more guidence +#> \ No newline at end of file From cff438f7f5efd58208d3dafb74350d88aa74c2ac Mon Sep 17 00:00:00 2001 From: jpomfret Date: Sun, 20 Jan 2019 08:53:39 -0500 Subject: [PATCH 2/2] fix encoding --- tests/Import-DbatoolsConfig.Tests.ps1 | 4 ++-- tests/Invoke-DbaAgFailover.Tests.ps1 | 4 ++-- tests/Join-DbaAvailabilityGroup.Tests.ps1 | 4 ++-- tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 | 4 ++-- tests/Reset-DbatoolsConfig.Tests.ps1 | 4 ++-- tests/Set-DbaDbCompatibility.Tests.ps1 | 4 ++-- tests/Sync-DbaAvailabilityGroup.Tests.ps1 | 4 ++-- tests/Unregister-DbatoolsConfig.Tests.ps1 | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/Import-DbatoolsConfig.Tests.ps1 b/tests/Import-DbatoolsConfig.Tests.ps1 index f26ff4242d..41253efd7f 100644 --- a/tests/Import-DbatoolsConfig.Tests.ps1 +++ b/tests/Import-DbatoolsConfig.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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 = 'Path','ModuleName','ModuleVersion','Scope','IncludeFilter','ExcludeFilter','Peek','EnableException' + [object[]]$knownParameters = 'Path', 'ModuleName', 'ModuleVersion', 'Scope', 'IncludeFilter', 'ExcludeFilter', 'Peek', 'EnableException' $knownParameters += [System.Management.Automation.PSCmdlet]::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-DbaAgFailover.Tests.ps1 b/tests/Invoke-DbaAgFailover.Tests.ps1 index 241805cc08..0634ae2f69 100644 --- a/tests/Invoke-DbaAgFailover.Tests.ps1 +++ b/tests/Invoke-DbaAgFailover.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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 = 'SqlInstance','SqlCredential','AvailabilityGroup','InputObject','Force','EnableException' + [object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', '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/Join-DbaAvailabilityGroup.Tests.ps1 b/tests/Join-DbaAvailabilityGroup.Tests.ps1 index 665f17093d..4581d22614 100644 --- a/tests/Join-DbaAvailabilityGroup.Tests.ps1 +++ b/tests/Join-DbaAvailabilityGroup.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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 = 'SqlInstance','SqlCredential','AvailabilityGroup','ClusterType','InputObject','EnableException' + [object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'AvailabilityGroup', 'ClusterType', '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-DbaDbBackupRestoreHistory.Tests.ps1 b/tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 index d5faa31959..00fa67bbba 100644 --- a/tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 +++ b/tests/Remove-DbaDbBackupRestoreHistory.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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 = 'SqlInstance','SqlCredential','KeepDays','Database','InputObject','EnableException' + [object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'KeepDays', '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/Reset-DbatoolsConfig.Tests.ps1 b/tests/Reset-DbatoolsConfig.Tests.ps1 index 9f07d0f4d3..2d8047c7a3 100644 --- a/tests/Reset-DbatoolsConfig.Tests.ps1 +++ b/tests/Reset-DbatoolsConfig.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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 = 'ConfigurationItem','FullName','Module','Name','EnableException' + [object[]]$knownParameters = 'ConfigurationItem', 'FullName', 'Module', '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/Set-DbaDbCompatibility.Tests.ps1 b/tests/Set-DbaDbCompatibility.Tests.ps1 index b1b1cc1ecc..c4d88cc487 100644 --- a/tests/Set-DbaDbCompatibility.Tests.ps1 +++ b/tests/Set-DbaDbCompatibility.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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 = 'SqlInstance','SqlCredential','Database','TargetCompatibility','InputObject','EnableException' + [object[]]$knownParameters = 'SqlInstance', 'SqlCredential', 'Database', 'TargetCompatibility', '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-DbaAvailabilityGroup.Tests.ps1 b/tests/Sync-DbaAvailabilityGroup.Tests.ps1 index f1bdde3ae0..50e527cecc 100644 --- a/tests/Sync-DbaAvailabilityGroup.Tests.ps1 +++ b/tests/Sync-DbaAvailabilityGroup.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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','Secondary','SecondarySqlCredential','AvailabilityGroup','Exclude','Login','ExcludeLogin','Job','ExcludeJob','InputObject','Force','EnableException' + [object[]]$knownParameters = 'Primary', 'PrimarySqlCredential', 'Secondary', 'SecondarySqlCredential', 'AvailabilityGroup', 'Exclude', 'Login', 'ExcludeLogin', 'Job', 'ExcludeJob', '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/Unregister-DbatoolsConfig.Tests.ps1 b/tests/Unregister-DbatoolsConfig.Tests.ps1 index 4b19db1a53..3848d27959 100644 --- a/tests/Unregister-DbatoolsConfig.Tests.ps1 +++ b/tests/Unregister-DbatoolsConfig.Tests.ps1 @@ -1,11 +1,11 @@ -$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "") +$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 = 'ConfigurationItem','FullName','Module','Name','Scope' + [object[]]$knownParameters = 'ConfigurationItem', 'FullName', 'Module', 'Name', 'Scope' $knownParameters += [System.Management.Automation.PSCmdlet]::CommonParameters It "Should only contain our specific parameters" { (@(Compare-Object -ReferenceObject ($knownParameters | Where-Object {$_}) -DifferenceObject $params).Count ) | Should Be 0