Files
PowerShell-PowerShell/test/powershell/Language/Scripting/OrderedAttributeForHashTables.Tests.ps1
T
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00

70 lines
2.6 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -Tags "CI" {
BeforeAll {
If (-not $IsCoreCLR) {
Get-WmiObject -Query "select * from win32_environment where name='TestWmiInstance'" | Remove-WmiObject
}
}
AfterAll {
If (-not $IsCoreCLR) {
Get-WmiObject -Query "select * from win32_environment where name='TestWmiInstance'" | Remove-WmiObject
}
}
It 'New-Object - Property Parameter Must take IDictionary' {
$a = new-object psobject -property ([ordered]@{one=1;two=2})
$a | Should Not Be $null
$a.one | Should Be 1
}
Context 'Select-Xml cmdlet - Namespace parameter must take IDictionary' {
$script:a = $null
$helpXml = @'
<?xml version="1.0" encoding="utf-8" ?>
<helpItems schema="maml">
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>
Stop-Transcript
</command:name>
</command:details>
</command:command>
</helpItems>
'@
{ $script:a = select-xml -content $helpXml -xpath "//command:name" -namespace (
[ordered]@{command="http://schemas.microsoft.com/maml/dev/command/2004/10";
maml="http://schemas.microsoft.com/maml/2004/10";
dev="http://schemas.microsoft.com/maml/dev/2004/10"}) } | Should Not Throw
It '$a should not be $null' { $script:a | Should Not Be $null }
}
It 'Set-WmiInstance cmdlet - Argument parameter must take IDictionary' -skip:$IsCoreCLR {
$script:a = $null
{ $script:a = set-wmiinstance -class win32_environment -argument ([ordered]@{Name="TestWmiInstance";
VariableValue="testvalu234e";
UserName="<SYSTEM>"}) } | Should Not Throw
$script:a | Should Not Be $null
$script:a.Name | Should Be "TestWmiInstance"
}
Context 'Select-Object cmdlet - Property parameter (Calculated properties) must take IDictionary' {
$script:a = $null
{$script:a = dir | select-object -property Name, (
[ordered]@{Name="IsDirectory";
Expression ={$_.PSIsContainer}})} | Should Not Throw
It '$a should not be $null' { $script:a | Should Not Be $null }
}
}