From e3940d45994195c4933267cfca8062e98de46ea5 Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 26 Dec 2017 08:38:20 +1300 Subject: [PATCH 1/2] Updated tests to meet Pester V4 guidelines --- README.md | 3 +- .../MSFT_xScheduledTask.Integration.Tests.ps1 | 52 ++++---- .../MSFT_xVirtualMemory.Integration.Tests.ps1 | 24 ++-- Tests/Unit/MSFT_xComputer.Tests.ps1 | 114 +++++++++--------- Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 | 18 +-- Tests/Unit/MSFT_xPowerPlan.Tests.ps1 | 20 +-- Tests/Unit/MSFT_xScheduledTask.Tests.ps1 | 114 +++++++++--------- Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 | 58 ++++----- 8 files changed, 202 insertions(+), 201 deletions(-) diff --git a/README.md b/README.md index b429a30a..f36c4ce0 100644 --- a/README.md +++ b/README.md @@ -223,7 +223,8 @@ xVirtualMemory has the following properties: * Updated to meet HQRM guidelines. * xComputer: * Resolved bug in Get-ComputerDomain where LocalSystem doesn't have - rights to the domain + rights to the domain. +* Updated tests to meet Pester V4 guidelines - See [Issue #106](https://github.com/PowerShell/xComputerManagement/issues/106). ### 3.2.0.0 diff --git a/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 b/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 index 18e28249..14a940bb 100644 --- a/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 @@ -59,7 +59,7 @@ try . $currentConfig ` -OutputPath $configDir ` -ConfigurationData $configData - } | Should Not Throw + } | Should -Not -Throw } It 'Should apply the MOF correctly' { @@ -70,11 +70,11 @@ try -Force ` -Verbose ` -ErrorAction Stop - } | Should Not Throw + } | Should -Not -Throw } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true } } @@ -88,7 +88,7 @@ try . $currentConfig ` -OutputPath $configDir ` -ConfigurationData $configData - } | Should Not Throw + } | Should -Not -Throw } It 'Should apply the MOF correctly' { @@ -99,11 +99,11 @@ try -Force ` -Verbose ` -ErrorAction Stop - } | Should Not Throw + } | Should -Not -Throw } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true } } @@ -117,7 +117,7 @@ try . $currentConfig ` -OutputPath $configDir ` -ConfigurationData $configData - } | Should Not Throw + } | Should -Not -Throw } It 'Should apply the MOF correctly' { @@ -128,11 +128,11 @@ try -Force ` -Verbose ` -ErrorAction Stop - } | Should Not Throw + } | Should -Not -Throw } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true } } } @@ -152,7 +152,7 @@ try Set-TimeZoneId -Id 'W. Australia Standard Time' . $currentConfig ` -OutputPath $configDir - } | Should Not Throw + } | Should -Not -Throw } It 'Should apply the MOF correctly in New Zealand Standard Time Timezone' { @@ -164,29 +164,29 @@ try -Force ` -Verbose ` -ErrorAction Stop - } | Should Not Throw + } | Should -Not -Throw } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true } It 'Should have set the resource and all the parameters should match' { $current = Get-DscConfiguration | Where-Object {$_.ConfigurationName -eq $currentConfig} - $current.TaskName | Should Be 'Test task once cross timezone' - $current.TaskPath | Should Be '\xComputerManagement\' - $current.ActionExecutable | Should Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' - $current.ScheduleType | Should Be 'Once' - $current.RepeatInterval | Should Be '00:15:00' - $current.RepetitionDuration | Should Be '23:00:00' - $current.ActionWorkingPath | Should Be (Get-Location).Path - $current.Enable | Should Be $true - $current.RandomDelay | Should Be '01:00:00' - $current.DisallowHardTerminate | Should Be $true - $current.RunOnlyIfIdle | Should Be $false - $current.Priority | Should Be 9 - $current.RunLevel | Should Be 'Limited' - $current.ExecutionTimeLimit | Should Be '00:00:00' + $current.TaskName | Should -Be 'Test task once cross timezone' + $current.TaskPath | Should -Be '\xComputerManagement\' + $current.ActionExecutable | Should -Be 'C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe' + $current.ScheduleType | Should -Be 'Once' + $current.RepeatInterval | Should -Be '00:15:00' + $current.RepetitionDuration | Should -Be '23:00:00' + $current.ActionWorkingPath | Should -Be (Get-Location).Path + $current.Enable | Should -Be $true + $current.RandomDelay | Should -Be '01:00:00' + $current.DisallowHardTerminate | Should -Be $true + $current.RunOnlyIfIdle | Should -Be $false + $current.Priority | Should -Be 9 + $current.RunLevel | Should -Be 'Limited' + $current.ExecutionTimeLimit | Should -Be '00:00:00' } AfterAll { diff --git a/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 b/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 index b03eaa5c..30532689 100644 --- a/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 @@ -35,17 +35,17 @@ try It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir - } | Should Not Throw + } | Should -Not -Throw } It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should Not Throw + } | Should -Not -Throw } It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true } } @@ -57,17 +57,17 @@ try It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir - } | Should Not Throw + } | Should -Not -Throw } It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should Not Throw + } | Should -Not -Throw } It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true } } @@ -79,17 +79,17 @@ try It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir - } | Should Not Throw + } | Should -Not -Throw } It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should Not Throw + } | Should -Not -Throw } It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true } } @@ -101,17 +101,17 @@ try It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir - } | Should Not Throw + } | Should -Not -Throw } It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force - } | Should Not Throw + } | Should -Not -Throw } It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true } } } diff --git a/Tests/Unit/MSFT_xComputer.Tests.ps1 b/Tests/Unit/MSFT_xComputer.Tests.ps1 index 0e6596cd..d7a64f90 100644 --- a/Tests/Unit/MSFT_xComputer.Tests.ps1 +++ b/Tests/Unit/MSFT_xComputer.Tests.ps1 @@ -59,7 +59,7 @@ try -DomainName 'contoso.com' ` -WorkGroupName 'workgroup' ` -Verbose - } | Should Throw $errorRecord + } | Should -Throw $errorRecord } It 'Throws if Domain is specified without Credentials' { @@ -72,7 +72,7 @@ try -Name $env:COMPUTERNAME ` -DomainName 'contoso.com' ` -Verbose - } | Should Throw $errorRecord + } | Should -Throw $errorRecord } It 'Should return True if Domain name is same as specified' { @@ -92,7 +92,7 @@ try -Name $env:COMPUTERNAME ` -DomainName 'Contoso.com' ` -Credential $credential ` - -Verbose | Should Be $true + -Verbose | Should -Be $true } It 'Should return True if Workgroup name is same as specified' { @@ -111,7 +111,7 @@ try Test-TargetResource ` -Name $env:COMPUTERNAME ` -WorkGroupName 'workgroup' ` - -Verbose | Should Be $true + -Verbose | Should -Be $true } It 'Should return True if ComputerName and Domain name is same as specified' { @@ -131,13 +131,13 @@ try -Name $env:COMPUTERNAME ` -DomainName 'contoso.com' ` -Credential $credential ` - -Verbose | Should Be $true + -Verbose | Should -Be $true Test-TargetResource ` -Name 'localhost' ` -DomainName 'contoso.com' ` -Credential $credential ` - -Verbose | Should Be $true + -Verbose | Should -Be $true } It 'Should return True if ComputerName and Workgroup is same as specified' { @@ -156,12 +156,12 @@ try Test-TargetResource ` -Name $env:COMPUTERNAME ` -WorkGroupName 'workgroup' ` - -Verbose | Should Be $true + -Verbose | Should -Be $true Test-TargetResource ` -Name 'localhost' ` -WorkGroupName 'workgroup' ` - -Verbose | Should Be $true + -Verbose | Should -Be $true } It 'Should return True if ComputerName is same and no Domain or Workgroup specified' { @@ -179,11 +179,11 @@ try Test-TargetResource ` -Name $env:COMPUTERNAME ` - -Verbose | Should Be $true + -Verbose | Should -Be $true Test-TargetResource ` -Name 'localhost' ` - -Verbose | Should Be $true + -Verbose | Should -Be $true Mock -CommandName Get-WmiObject { [PSCustomObject] @{ @@ -199,11 +199,11 @@ try Test-TargetResource ` -Name $env:COMPUTERNAME ` - -Verbose | Should Be $true + -Verbose | Should -Be $true Test-TargetResource ` -Name 'localhost' ` - -Verbose | Should Be $true + -Verbose | Should -Be $true } It 'Should return False if ComputerName is not same and no Domain or Workgroup specified' { @@ -221,7 +221,7 @@ try Test-TargetResource ` -Name $notComputerName ` - -Verbose | Should Be $false + -Verbose | Should -Be $false Mock -CommandName Get-WmiObject -MockWith { [PSCustomObject] @{ @@ -237,7 +237,7 @@ try Test-TargetResource ` -Name $notComputerName ` - -Verbose | Should Be $false + -Verbose | Should -Be $false } It 'Should return False if Domain name is not same as specified' { @@ -257,13 +257,13 @@ try -Name $env:COMPUTERNAME ` -DomainName 'adventure-works.com' ` -Credential $credential ` - -Verbose | Should Be $false + -Verbose | Should -Be $false Test-TargetResource ` -Name 'localhost' ` -DomainName 'adventure-works.com' ` -Credential $credential ` - -Verbose | Should Be $false + -Verbose | Should -Be $false } It 'Should return False if Workgroup name is not same as specified' { @@ -282,12 +282,12 @@ try Test-TargetResource ` -Name $env:COMPUTERNAME ` -WorkGroupName 'NOTworkgroup' ` - -Verbose | Should Be $false + -Verbose | Should -Be $false Test-TargetResource ` -Name 'localhost' ` -WorkGroupName 'NOTworkgroup' ` - -Verbose | Should Be $false + -Verbose | Should -Be $false } It 'Should return False if ComputerName is not same as specified' { @@ -306,7 +306,7 @@ try Test-TargetResource ` -Name $notComputerName ` -WorkGroupName 'workgroup' ` - -Verbose | Should Be $false + -Verbose | Should -Be $false Mock -CommandName Get-WMIObject -MockWith { [PSCustomObject] @{ @@ -324,7 +324,7 @@ try -Name $notComputerName ` -DomainName 'contoso.com' ` -Credential $credential ` - -Verbose | Should Be $false + -Verbose | Should -Be $false } It 'Should return False if Computer is in Workgroup and Domain is specified' { @@ -344,13 +344,13 @@ try -Name $env:COMPUTERNAME ` -DomainName 'contoso.com' ` -Credential $credential ` - -Verbose | Should Be $false + -Verbose | Should -Be $false Test-TargetResource ` -Name 'localhost' ` -DomainName 'contoso.com' ` -Credential $credential ` - -Verbose | Should Be $false + -Verbose | Should -Be $false } It 'Should return False if ComputerName is in Domain and Workgroup is specified' { @@ -371,14 +371,14 @@ try -WorkGroupName 'Contoso' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should Be $false + -Verbose | Should -Be $false Test-TargetResource ` -Name 'localhost' ` -WorkGroupName 'Contoso' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should Be $false + -Verbose | Should -Be $false } It 'Throws if name is to long' { @@ -386,7 +386,7 @@ try Test-TargetResource ` -Name 'ThisNameIsTooLong' ` -Verbose - } | Should Throw + } | Should -Throw } It 'Throws if name contains illegal characters' { @@ -394,7 +394,7 @@ try Test-TargetResource ` -Name 'ThisIsBad<>' ` -Verbose - } | Should Throw + } | Should -Throw } It 'Should not Throw if name is localhost' { @@ -402,7 +402,7 @@ try Test-TargetResource ` -Name 'localhost' ` -Verbose - } | Should Not Throw + } | Should -Not -Throw } It 'Should return true if description is same as specified' { @@ -415,12 +415,12 @@ try Test-TargetResource ` -Name $env:COMPUTERNAME ` -Description 'This is my computer' ` - -Verbose | Should Be $true + -Verbose | Should -Be $true Test-TargetResource ` -Name 'localhost' ` -Description 'This is my computer' ` - -Verbose | Should Be $true + -Verbose | Should -Be $true } It 'Should return false if description is same as specified' { @@ -433,12 +433,12 @@ try Test-TargetResource ` -Name $env:COMPUTERNAME ` -Description 'This is my computer' ` - -Verbose | Should Be $false + -Verbose | Should -Be $false Test-TargetResource ` -Name 'localhost' ` -Description 'This is my computer' ` - -Verbose | Should Be $false + -Verbose | Should -Be $false } } @@ -448,7 +448,7 @@ try Get-TargetResource ` -Name $env:COMPUTERNAME ` -Verbose - } | Should Not Throw + } | Should -Not -Throw } It 'Should return a hashtable containing Name, DomainName, JoinOU, CurrentOU, Credential, UnjoinCredential, WorkGroupName and Description' { @@ -456,8 +456,8 @@ try -Name $env:COMPUTERNAME ` -Verbose - $Result.GetType().Fullname | Should Be 'System.Collections.Hashtable' - $Result.Keys | Sort-Object | Should Be @('Credential', 'CurrentOU', 'Description', 'DomainName', 'JoinOU', 'Name', 'UnjoinCredential', 'WorkGroupName') + $Result.GetType().Fullname | Should -Be 'System.Collections.Hashtable' + $Result.Keys | Sort-Object | Should -Be @('Credential', 'CurrentOU', 'Description', 'DomainName', 'JoinOU', 'Name', 'UnjoinCredential', 'WorkGroupName') } It 'Throws if name is to long' { @@ -465,7 +465,7 @@ try Get-TargetResource ` -Name 'ThisNameIsTooLong' ` -Verbose - } | Should Throw + } | Should -Throw } It 'Throws if name contains illegal characters' { @@ -473,7 +473,7 @@ try Get-TargetResource ` -Name 'ThisIsBad<>' ` -Verbose - } | Should Throw + } | Should -Throw } } @@ -492,7 +492,7 @@ try -DomainName 'contoso.com' ` -WorkGroupName 'workgroup' ` -Verbose - } | Should Throw $errorRecord + } | Should -Throw $errorRecord Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It @@ -508,7 +508,7 @@ try -Name $env:COMPUTERNAME ` -DomainName 'contoso.com' ` -Verbose - } | Should Throw $errorRecord + } | Should -Throw $errorRecord Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It @@ -532,7 +532,7 @@ try -DomainName 'adventure-works.com' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName -and $NewName } @@ -558,7 +558,7 @@ try -JoinOU 'OU=Computers,DC=contoso,DC=com' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName -and $NewName } @@ -582,7 +582,7 @@ try -Name $notComputerName ` -WorkGroupName 'contoso' ` -Credential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $WorkGroupName -and $NewName -and $credential } @@ -606,7 +606,7 @@ try -Name $notComputerName ` -DomainName 'Contoso.com' ` -Credential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName -and $NewName } @@ -631,7 +631,7 @@ try -DomainName 'Contoso.com' ` -JoinOU 'OU=Computers,DC=contoso,DC=com' ` -Credential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName -and $NewName } @@ -654,7 +654,7 @@ try Set-TargetResource ` -Name $notComputerName ` -WorkGroupName 'adventure-works' ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $WorkGroupName -and $NewName } @@ -679,7 +679,7 @@ try -DomainName 'adventure-works.com' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName } @@ -705,7 +705,7 @@ try -DomainName 'adventure-works.com' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName } @@ -732,7 +732,7 @@ try -JoinOU 'OU=Computers,DC=contoso,DC=com' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName } @@ -759,7 +759,7 @@ try -JoinOU 'OU=Computers,DC=contoso,DC=com' ` -Credential $credential ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 1 -Scope It -ParameterFilter { $DomainName } @@ -784,7 +784,7 @@ try -Name $env:COMPUTERNAME ` -WorkGroupName 'Contoso' ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It -ParameterFilter { $NewName } @@ -809,7 +809,7 @@ try -Name 'localhost' ` -WorkGroupName 'Contoso' ` -UnjoinCredential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 0 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It -ParameterFilter { $NewName } @@ -833,7 +833,7 @@ try Set-TargetResource ` -Name $notComputerName ` -Credential $credential ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 1 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It @@ -854,7 +854,7 @@ try Set-TargetResource ` -Name $notComputerName ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Rename-Computer -Exactly -Times 1 -Scope It Assert-MockCalled -CommandName Add-Computer -Exactly -Times 0 -Scope It @@ -865,7 +865,7 @@ try Set-TargetResource ` -Name 'ThisNameIsTooLong' ` -Verbose - } | Should Throw + } | Should -Throw } It 'Throws if name contains illegal characters' { @@ -873,7 +873,7 @@ try Set-TargetResource ` -Name 'ThisIsBad<>' ` -Verbose - } | Should Throw + } | Should -Throw } It 'Changes computer description in a workgroup' { @@ -893,7 +893,7 @@ try -Name $env:COMPUTERNAME ` -Description 'This is my computer' ` -DomainName '' ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Set-CimInstance -Exactly -Times 1 -Scope It } @@ -913,7 +913,7 @@ try Set-TargetResource ` -Name $env:COMPUTERNAME ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Set-TargetResource ` -Name $env:COMPUTERNAME ` @@ -921,7 +921,7 @@ try -Credential $credential ` -UnjoinCredential $credential ` -Description 'This is my computer' ` - -Verbose | Should BeNullOrEmpty + -Verbose | Should -BeNullOrEmpty Assert-MockCalled -CommandName Set-CimInstance -Exactly -Times 1 -Scope It } diff --git a/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 b/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 index 388e1a2b..babc3514 100644 --- a/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 +++ b/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 @@ -37,8 +37,8 @@ try $result = Get-TargetResource ` @TestOfflineDomainJoin - $result.IsSingleInstance | Should Be $testOfflineDomainJoin.IsSingleInstance - $result.RequestFile | Should Be '' + $result.IsSingleInstance | Should -Be $testOfflineDomainJoin.IsSingleInstance + $result.RequestFile | Should -Be '' } } @@ -51,7 +51,7 @@ try Mock -CommandName Join-Domain It 'Should not throw exception' { - { Set-TargetResource @TestOfflineDomainJoin } | Should Not Throw + { Set-TargetResource @TestOfflineDomainJoin } | Should -Not -Throw } It 'Should do call all the mocks' { @@ -72,7 +72,7 @@ try -Message ($LocalizedData.RequestFileNotFoundError -f $testOfflineDomainJoin.RequestFile) ` -ArgumentName 'RequestFile' - { Test-TargetResource @TestOfflineDomainJoin } | Should Throw $errorRecord + { Test-TargetResource @TestOfflineDomainJoin } | Should -Throw $errorRecord } It 'Should do call all the mocks' { @@ -93,7 +93,7 @@ try } It 'Should return false' { - Test-TargetResource @TestOfflineDomainJoin | should be $false + Test-TargetResource @TestOfflineDomainJoin | should -be $false } It 'Should do call all the mocks' { @@ -112,7 +112,7 @@ try } It 'Should return false' { - Test-TargetResource @TestOfflineDomainJoin | should be $true + Test-TargetResource @TestOfflineDomainJoin | should -be $true } It 'Should do call all the mocks' { @@ -135,7 +135,7 @@ try -Message ($LocalizedData.RequestFileNotFoundError -f $testOfflineDomainJoin.RequestFile) ` -ArgumentName 'RequestFile' - { Test-TargetResource @TestOfflineDomainJoin } | Should Throw $errorRecord + { Test-TargetResource @TestOfflineDomainJoin } | Should -Throw $errorRecord } It 'Should do call all the mocks' { @@ -153,7 +153,7 @@ try } It 'Should not throw' { - { Join-Domain -RequestFile 'c:\doesnotmatter.txt' } | Should Not Throw + { Join-Domain -RequestFile 'c:\doesnotmatter.txt' } | Should -Not -Throw } It 'Should do call all the mocks' { @@ -171,7 +171,7 @@ try -Message $($LocalizedData.DjoinError -f 99) It 'Should not throw' { - { Join-Domain -RequestFile 'c:\doesnotmatter.txt' } | Should Throw $errorRecord + { Join-Domain -RequestFile 'c:\doesnotmatter.txt' } | Should -Throw $errorRecord } It 'Should do call all the mocks' { diff --git a/Tests/Unit/MSFT_xPowerPlan.Tests.ps1 b/Tests/Unit/MSFT_xPowerPlan.Tests.ps1 index aee131fc..91548927 100644 --- a/Tests/Unit/MSFT_xPowerPlan.Tests.ps1 +++ b/Tests/Unit/MSFT_xPowerPlan.Tests.ps1 @@ -55,8 +55,8 @@ try It 'Should return the same values as passed as parameters' { $result = Get-TargetResource @testParameters - $result.IsSingleInstance | Should Be 'Yes' - $result.Name | Should Be $testParameters.Name + $result.IsSingleInstance | Should -Be 'Yes' + $result.Name | Should -Be $testParameters.Name } } @@ -74,8 +74,8 @@ try It 'Should not return any plan name' { $result = Get-TargetResource @testParameters - $result.IsSingleInstance | Should Be 'Yes' - $result.Name | Should Be $null + $result.IsSingleInstance | Should -Be 'Yes' + $result.Name | Should -Be $null } } @@ -92,7 +92,7 @@ try $errorRecord = Get-InvalidOperationRecord ` -Message ($LocalizedData.PowerPlanCimError -f 'Win32_PowerPlan') - { Get-TargetResource @testParameters } | Should Throw $errorRecord + { Get-TargetResource @testParameters } | Should -Throw $errorRecord } } @@ -108,7 +108,7 @@ try $errorRecord = Get-InvalidOperationRecord ` -Message ($LocalizedData.PowerPlanNotFound -f $testParameters.Name) - { Get-TargetResource @testParameters } | Should Throw $errorRecord + { Get-TargetResource @testParameters } | Should -Throw $errorRecord } } @@ -160,7 +160,7 @@ try $errorRecord = Get-InvalidOperationRecord ` -Message ($LocalizedData.PowerPlanCimError -f 'Win32_PowerPlan') - { Set-TargetResource @testParameters } | Should Throw $errorRecord + { Set-TargetResource @testParameters } | Should -Throw $errorRecord } } @@ -177,7 +177,7 @@ try $errorRecord = Get-InvalidOperationRecord ` -Message ($LocalizedData.PowerPlanWasUnableToBeSet -f $testParameters.Name, 'Failed to set value') - { Set-TargetResource @testParameters } | Should Throw $errorRecord + { Set-TargetResource @testParameters } | Should -Throw $errorRecord } } @@ -206,7 +206,7 @@ try } It 'Should return the the state as present ($true)' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } @@ -223,7 +223,7 @@ try } It 'Should return the the state as absent ($false)' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } } diff --git a/Tests/Unit/MSFT_xScheduledTask.Tests.ps1 b/Tests/Unit/MSFT_xScheduledTask.Tests.ps1 index 7abc3c75..00d9e155 100644 --- a/Tests/Unit/MSFT_xScheduledTask.Tests.ps1 +++ b/Tests/Unit/MSFT_xScheduledTask.Tests.ps1 @@ -56,11 +56,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Absent' + $result.Ensure | Should -Be 'Absent' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should create the scheduled task in the set method' { @@ -102,11 +102,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should remove the scheduled task in the set method' { @@ -129,11 +129,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Absent' + $result.Ensure | Should -Be 'Absent' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } @@ -170,11 +170,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -217,11 +217,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } @@ -258,11 +258,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -305,11 +305,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } @@ -345,11 +345,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -388,11 +388,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } @@ -430,11 +430,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -480,12 +480,12 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' - $result.LogonType | Should Be 'Password' + $result.Ensure | Should -Be 'Present' + $result.LogonType | Should -Be 'Password' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -531,12 +531,12 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' - $result.RunLevel | Should Be 'Limited' + $result.Ensure | Should -Be 'Present' + $result.RunLevel | Should -Be 'Limited' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -581,11 +581,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -630,11 +630,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -682,11 +682,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -737,11 +737,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -801,11 +801,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } @@ -847,11 +847,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } @@ -893,11 +893,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -944,33 +944,33 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } Context 'A scheduled task path is root or custom' -Fixture { It 'Should return backslash' { - ConvertTo-NormalizedTaskPath -TaskPath '\'| Should Be '\' + ConvertTo-NormalizedTaskPath -TaskPath '\'| Should -Be '\' } It 'Should add backslash at the end' { - ConvertTo-NormalizedTaskPath -TaskPath '\Test'| Should Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath '\Test'| Should -Be '\Test\' } It 'Should add backslash at the beginning' { - ConvertTo-NormalizedTaskPath -TaskPath 'Test\'| Should Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath 'Test\'| Should -Be '\Test\' } It 'Should add backslash at the beginning and at the end' { - ConvertTo-NormalizedTaskPath -TaskPath 'Test'| Should Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath 'Test'| Should -Be '\Test\' } It 'Should not add backslash' { - ConvertTo-NormalizedTaskPath -TaskPath '\Test\'| Should Be '\Test\' + ConvertTo-NormalizedTaskPath -TaskPath '\Test\'| Should -Be '\Test\' } } @@ -1022,11 +1022,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -1084,11 +1084,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -1132,11 +1132,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -1180,11 +1180,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return false from the test method' { - Test-TargetResource @testParameters | Should Be $false + Test-TargetResource @testParameters | Should -Be $false } It 'Should update the scheduled task in the set method' { @@ -1228,11 +1228,11 @@ try It 'Should return the correct values from Get-TargetResource' { $result = Get-TargetResource @testParameters - $result.Ensure | Should Be 'Present' + $result.Ensure | Should -Be 'Present' } It 'Should return true from the test method' { - Test-TargetResource @testParameters | Should Be $true + Test-TargetResource @testParameters | Should -Be $true } } } diff --git a/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 b/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 index 6a48cc3b..701dc9fe 100644 --- a/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 +++ b/Tests/Unit/MSFT_xVirtualMemory.Tests.ps1 @@ -131,7 +131,7 @@ try { It 'Should return type set to AutoManagePagingFile' { $result = Get-TargetResource @testParameters - $result.Type | Should Be 'AutoManagePagingFile' + $result.Type | Should -Be 'AutoManagePagingFile' } It 'Should call the correct mocks' { @@ -154,7 +154,7 @@ try { It 'Should return type set to NoPagingFile' { $result = Get-TargetResource @testParameters - $result.Type | Should Be 'NoPagingFile' + $result.Type | Should -Be 'NoPagingFile' } It 'Should call the correct mocks' { @@ -189,8 +189,8 @@ try { It 'Should return a expected type and drive letter' { $result = Get-TargetResource @testParameters - $result.Type | Should Be 'SystemManagedSize' - $result.Drive | Should Be ([System.IO.DriveInfo] $testParameters.Drive).Name + $result.Type | Should -Be 'SystemManagedSize' + $result.Drive | Should -Be ([System.IO.DriveInfo] $testParameters.Drive).Name } It 'Should call the correct mocks' { @@ -225,8 +225,8 @@ try { It 'Should return expected type and drive letter' { $result = Get-TargetResource @testParameters - $result.Type | Should Be 'CustomSize' - $result.Drive | Should Be ([System.IO.DriveInfo] $testParameters.Drive).Name + $result.Type | Should -Be 'CustomSize' + $result.Drive | Should -Be ([System.IO.DriveInfo] $testParameters.Drive).Name } It 'Should call the correct mocks' { @@ -283,7 +283,7 @@ try { Verbose = $true } - { Set-TargetResource @testParameters } | Should Not Throw + { Set-TargetResource @testParameters } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -335,7 +335,7 @@ try { Verbose = $true } - { Set-TargetResource @testParameters } | Should Not Throw + { Set-TargetResource @testParameters } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -406,7 +406,7 @@ try { Verbose = $true } - { Set-TargetResource @testParameters } | Should Not Throw + { Set-TargetResource @testParameters } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -473,7 +473,7 @@ try { Verbose = $true } - { Set-TargetResource @testParameters } | Should Not Throw + { Set-TargetResource @testParameters } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -539,7 +539,7 @@ try { Verbose = $true } - { Set-TargetResource @testParameters } | Should Not Throw + { Set-TargetResource @testParameters } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -597,7 +597,7 @@ try { Verbose = $true } - { Set-TargetResource @testParameters } | Should Not Throw + { Set-TargetResource @testParameters } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -648,7 +648,7 @@ try { Verbose = $true } - { Set-TargetResource @testParameters } | Should Not Throw + { Set-TargetResource @testParameters } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -693,7 +693,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $true + $result | Should -Be $true } It 'Should call the correct mocks' { @@ -724,7 +724,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $true + $result | Should -Be $true } It 'Should call the correct mocks' { @@ -767,7 +767,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $true + $result | Should -Be $true } It 'Should call the correct mocks' { @@ -810,7 +810,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $true + $result | Should -Be $true } It 'Should call the correct mocks' { @@ -844,7 +844,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should call the correct mocks' { @@ -882,7 +882,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should call the correct mocks' { @@ -925,7 +925,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should call the correct mocks' { @@ -968,7 +968,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should call the correct mocks' { @@ -1011,7 +1011,7 @@ try { } $result = Test-TargetResource @testParameters - $result | Should Be $false + $result | Should -Be $false } It 'Should call the correct mocks' { @@ -1043,9 +1043,9 @@ try { It 'Should return the expected object' { $result = Get-PageFileSetting -Drive $testDrive -Verbose - $result.InitialSize | Should Be $testInitialSize - $result.MaximumSize | Should Be $testMaximumSize - $result.Name | Should Be "$testDrive\" + $result.InitialSize | Should -Be $testInitialSize + $result.MaximumSize | Should -Be $testMaximumSize + $result.Name | Should -Be "$testDrive\" } It 'Should call the correct mocks' { @@ -1070,7 +1070,7 @@ try { -InitialSize $testInitialSize ` -MaximumSize $testMaximumSize ` -Verbose - } | Should Not Throw + } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -1089,7 +1089,7 @@ try { -ParameterFilter $parameterFilterEnableAutoManagePaging It 'Should not throw an exception' { - { Set-AutoManagePaging -State Enable -Verbose } | Should Not Throw + { Set-AutoManagePaging -State Enable -Verbose } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -1106,7 +1106,7 @@ try { -ParameterFilter $parameterFilterDisableAutoManagePaging It 'Should not throw an exception' { - { Set-AutoManagePaging -State Disable -Verbose } | Should Not Throw + { Set-AutoManagePaging -State Disable -Verbose } | Should -Not -Throw } It 'Should call the correct mocks' { @@ -1125,7 +1125,7 @@ try { -ParameterFilter $parameterFilterNewPageFileSetting It 'Should not throw an exception' { - { New-PageFile -PageFileName $testPageFileName -Verbose } | Should Not Throw + { New-PageFile -PageFileName $testPageFileName -Verbose } | Should -Not -Throw } It 'Should call the correct mocks' { From 7447456d2b81ede72dd5477a6d5bd1b357b4eb9a Mon Sep 17 00:00:00 2001 From: Daniel Scott-Raynsford Date: Tue, 26 Dec 2017 08:50:20 +1300 Subject: [PATCH 2/2] Minor changes to Case in Tests --- .../MSFT_xScheduledTask.Integration.Tests.ps1 | 8 ++-- .../MSFT_xVirtualMemory.Integration.Tests.ps1 | 38 +++++++++---------- Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 | 4 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 b/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 index 14a940bb..9ff49022 100644 --- a/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xScheduledTask.Integration.Tests.ps1 @@ -74,7 +74,7 @@ try } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true } } @@ -103,7 +103,7 @@ try } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true } } @@ -132,7 +132,7 @@ try } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true } } } @@ -168,7 +168,7 @@ try } It 'Should return a compliant state after being applied' { - (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $configMof -Verbose).InDesiredState | Should -Be $true } It 'Should have set the resource and all the parameters should match' { diff --git a/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 b/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 index 30532689..f46f6739 100644 --- a/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xVirtualMemory.Integration.Tests.ps1 @@ -1,5 +1,5 @@ -$script:DSCModuleName = 'xComputerManagement' -$script:DSCResourceName = 'MSFT_xVirtualMemory' +$script:DSCModuleName = 'xComputerManagement' +$script:DSCResourceName = 'MSFT_xVirtualMemory' #region HEADER # Integration Test Template Version: 1.1.1 @@ -26,26 +26,26 @@ try . $configFile Describe "$($script:DSCResourceName)_Integration" { - + Context "Set page file to automatically managed" { $CurrentConfig = "setToAuto" $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof") - + It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir } | Should -Not -Throw } - + It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force } | Should -Not -Throw } - + It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true } } @@ -53,21 +53,21 @@ try $CurrentConfig = "setToCustom" $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof") - + It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir } | Should -Not -Throw } - + It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force } | Should -Not -Throw } - + It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true } } @@ -75,21 +75,21 @@ try $CurrentConfig = "setToSystemManaged" $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof") - + It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir } | Should -Not -Throw } - + It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force } | Should -Not -Throw } - + It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true } } @@ -97,21 +97,21 @@ try $CurrentConfig = "setToNone" $ConfigDir = (Join-Path -Path $TestDrive -ChildPath $CurrentConfig) $ConfigMof = (Join-Path -Path $ConfigDir -ChildPath "localhost.mof") - + It "should compile a MOF file without error" { { . $CurrentConfig -OutputPath $ConfigDir } | Should -Not -Throw } - + It "should apply the MOF correctly" { { Start-DscConfiguration -Path $ConfigDir -Wait -Verbose -Force } | Should -Not -Throw } - + It "should return a compliant state after being applied" { - (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -be $true + (Test-DscConfiguration -ReferenceConfiguration $ConfigMof -Verbose).InDesiredState | Should -Be $true } } } diff --git a/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 b/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 index babc3514..5d301ef1 100644 --- a/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 +++ b/Tests/Unit/MSFT_xOfflineDomainJoin.Tests.ps1 @@ -93,7 +93,7 @@ try } It 'Should return false' { - Test-TargetResource @TestOfflineDomainJoin | should -be $false + Test-TargetResource @TestOfflineDomainJoin | Should -Be $false } It 'Should do call all the mocks' { @@ -112,7 +112,7 @@ try } It 'Should return false' { - Test-TargetResource @TestOfflineDomainJoin | should -be $true + Test-TargetResource @TestOfflineDomainJoin | Should -Be $true } It 'Should do call all the mocks' {