PowerShell/test/powershell/engine/ETS/CimAdapter.Tests.ps1
xtqqczze 1f252f8bba
Wrap tests in pester blocks (#12700)
# PR Summary

Wrap tests in pester blocks to prepare for pesterv5

## PR Context

<!-- Provide a little reasoning as to why this Pull Request helps and why you have opened it. -->

## PR Checklist

- [x] [PR has a meaningful title](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
    - Use the present tense and imperative mood when describing your changes
- [x] [Summarized changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] [Make sure all `.h`, `.cpp`, `.cs`, `.ps1` and `.psm1` files have the correct copyright header](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
- [x] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress).
    - If the PR is work in progress, please add the prefix `WIP:` or `[ WIP ]` to the beginning of the title (the `WIP` bot will keep its status check at `Pending` while the prefix is present) and remove the prefix when the PR is ready.
- **[Breaking changes](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)**
    - [x] None
    - **OR**
    - [ ] [Experimental feature(s) needed](https://github.com/MicrosoftDocs/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Experimental_Features.md)
        - [ ] Experimental feature name(s): <!-- Experimental feature name(s) here -->
- **User-facing changes**
    - [x] Not Applicable
    - **OR**
    - [ ] [Documentation needed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---submission)
        - [ ] Issue filed: <!-- Number/link of that issue here -->
- **Testing - New and feature**
    - [x] N/A or can only be tested interactively
    - **OR**
    - [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
- **Tooling**
    - [x] I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    - **OR**
    - [ ] I have considered the user experience from a tooling perspective and enumerated concerns in the summary. This may include:
        - Impact on [PowerShell Editor Services](https://github.com/PowerShell/PowerShellEditorServices) which is used in the [PowerShell extension](https://github.com/PowerShell/vscode-powershell) for VSCode (which runs in a different PS Host).
        - Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        - Impact on [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) (which provides linting & formatting in the editor extensions).
        - Impact on [EditorSyntax](https://github.com/PowerShell/EditorSyntax) (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
2020-05-23 13:24:53 +00:00

88 lines
4 KiB
PowerShell

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "CIM Objects are adapted properly" -Tag @("CI") {
BeforeAll {
function getIndex
{
param([string[]]$strings,[string]$pattern)
for ($i = 0; $i -lt $strings.Count; $i++) {
if ($strings[$i] -like $pattern) {
return $i
}
}
return -1
}
if ( ! $IsWindows ) {
$PSDefaultParameterValues["it:pending"] = $true
}
else {
$p = Get-CimInstance win32_process |Select-Object -First 1
$indexOf_namespaceQualified_Win32Process = getIndex $p.PSTypeNames "*root?cimv2?Win32_Process"
$indexOf_namespaceQualified_CimProcess = getIndex $p.PSTypeNames "*root?cimv2?CIM_Process"
$indexOf_namespaceQualified_CimLogicalElement = getIndex $p.PSTypeNames "*root?cimv2?CIM_LogicalElement"
$indexOf_namespaceQualified_CimManagedSystemElement = getIndex $p.PSTypeNames "*root?cimv2?CIM_ManagedSystemElement"
$indexOf_className_Win32Process = getIndex $p.PSTypeNames "*#Win32_Process"
$indexOf_className_CimProcess = getIndex $p.PSTypeNames "*#CIM_Process"
$indexOf_className_CimLogicalElement = getIndex $p.PSTypeNames "*#CIM_LogicalElement"
$indexOf_className_CimManagedSystemElement = getIndex $p.PSTypeNames "*#CIM_ManagedSystemElement"
}
}
AfterAll {
$PSDefaultParameterValues.Remove("it:pending")
}
It "Namespace-qualified Win32_Process is present" -Skip:(!$IsWindows) {
$indexOf_namespaceQualified_Win32Process | Should -Not -Be (-1)
}
It "Namespace-qualified CIM_Process is present" {
$indexOf_namespaceQualified_CimProcess | Should -Not -Be (-1)
}
It "Namespace-qualified CIM_LogicalElement is present" {
$indexOf_namespaceQualified_CimLogicalElement | Should -Not -Be (-1)
}
It "Namespace-qualified CIM_ManagedSystemElement is present" {
$indexOf_namespaceQualified_CimManagedSystemElement | Should -Not -Be (-1)
}
It "Classname of Win32_Process is present" -Skip:(!$IsWindows) {
$indexOf_className_Win32Process | Should -Not -Be (-1)
}
It "Classname of CIM_Process is present" {
$indexOf_className_CimProcess | Should -Not -Be (-1)
}
It "Classname of CIM_LogicalElement is present" {
$indexOf_className_CimLogicalElement | Should -Not -Be (-1)
}
It "Classname of CIM_ManagedSystemElement is present" {
$indexOf_className_CimManagedSystemElement | Should -Not -Be (-1)
}
It "Win32_Process comes after CIM_Process (namespace qualified)" -Skip:(!$IsWindows) {
$indexOf_namespaceQualified_Win32Process | Should -BeLessThan $indexOf_namespaceQualified_CimProcess
}
It "CIM_Process comes after CIM_LogicalElement (namespace qualified)" {
$indexOf_namespaceQualified_CimProcess | Should -BeLessThan $indexOf_namespaceQualified_CimLogicalElement
}
It "CIM_LogicalElement comes after CIM_ManagedSystemElement (namespace qualified)" {
$indexOf_namespaceQualified_CimLogicalElement | Should -BeLessThan $indexOf_namespaceQualified_CimManagedSystemElement
}
It "Win32_Process comes after CIM_Process (classname only)" -Skip:(!$IsWindows) {
$indexOf_className_Win32Process | Should -BeLessThan $indexOf_className_CimProcess
}
It "CIM_Process comes after CIM_LogicalElement (classname only)" {
$indexOf_className_CimProcess | Should -BeLessThan $indexOf_className_CimLogicalElement
}
It "CIM_LogicalElement comes after CIM_ManagedSystemElement (classname only)" {
$indexOf_className_CimLogicalElement | Should -BeLessThan $indexOf_className_CimManagedSystemElement
}
It "Namespace qualified PSTypenames comes after class-only PSTypeNames" -Skip:(!$IsWindows) {
$indexOf_namespaceQualified_CimManagedSystemElement | Should -BeLessThan $indexOf_className_Win32Process
}
}