Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/Get-HotFix.Tests.ps1
T
xtqqczze 743983390e Update pester syntax to v4 (#11544)
* Capitalize 'Should' command and fix whitespace

```powershell
$_ -ireplace '\s?\|\s?should\b',' | Should'
```

* Capitalise and apply hyphen to 'Not' parameter

```powershell
$_ -ireplace '(\| Should) not\b','$1 -Not'
```

* Capitalise and apply hyphen to 'Be' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -?be\b','$1 -Be'
```

* Capitalise and apply hyphen to 'BeExactly' parameter

$_ -ireplace '(\| Should(?: -Not)?) -?beexactly\b','$1 -BeExactly'

* Capitalise and apply hyphen to 'BeGreaterThan' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -?begreaterthan\b','$1 -BeGreaterThan'
```

* Use 'BeTrue' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?true\b','$1 -BeTrue'
```

* Use 'BeFalse' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?false\b','$1 -BeFalse'
```

* Capitalise and apply hyphen to 'Match' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?match\b','$1 -Match'
```

* Capitalise and apply hyphen to 'Throw' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?throw\b','$1 -Throw'
```

* Capitalise and apply hyphen to 'BeNullOrEmpty' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?benullorempty\b','$1 -BeNullOrEmpty'
```

* Capitalise 'Because' parameter

```powershell
$_ -ireplace '\s-because\b',' -Because'
```

* Fix 'BeNullOrEmpty'
2020-01-11 20:41:59 +05:00

67 lines
2.1 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe "Get-HotFix Tests" -Tag CI {
BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$skip = $false
if (!$IsWindows) {
$skip = $true
}
else {
# skip the tests if there are no hotfixes returned
$qfe = Get-CimInstance Win32_QuickFixEngineering
if ($qfe.Count -eq 0) {
$skip = $true
}
}
$PSDefaultParameterValues["it:skip"] = $skip
}
AfterAll {
$global:PSDefaultParameterValues = $originalDefaultParameterValues
}
It "Get-HotFix will enumerate all QFEs" {
$hotfix = Get-HotFix
$hotfix.Count | Should -Be $qfe.Count
}
It "Get-HotFix can filter on -Id" {
$testQfe = $qfe[0]
$hotfix = Get-HotFix -Id $testQfe.HotFixID
$hotfix.HotFixID | Should -BeExactly $testQfe.HotFixID
$hotfix.Description | Should -BeExactly $testQfe.Description
}
It "Get-HotFix can filter on -Description" {
$testQfes = $qfe | Where-Object { $_.Description -eq 'Update' }
if ($testQfes.Count -gt 0) {
$hotfixes = Get-HotFix -Description 'Update'
}
elseif ($qfe.Count -gt 0) {
$description = $qfe[0].Description
$testQfes = $qfe | Where-Object { $_.Description -eq $description }
$hotfixes = Get-HotFix -Desscription $description
}
# if no applicable qfes are found on test system, this test will still
# pass as both will have count 0
$hotfixes.Count | Should -Be $testQfes.Count
}
It "Get-HotFix can use -ComputerName" {
$hotfixes = Get-HotFix -ComputerName localhost
$hotfixes.Count | Should -Be $qfe.Count
}
It "Get-Hotfix can accept ComputerName via pipeline" {
{ [PSCustomObject]@{ComputerName = 'UnavailableComputer'} | Get-HotFix } | Should -Throw -ErrorID 'Microsoft.PowerShell.Commands.GetHotFixCommand'
[PSCustomObject]@{ComputerName = 'localhost'} | Get-HotFix | Should -Not -BeNullOrEmpty
}
}