Autocorrected CRLF to LF (#4943)

Also, fix `Parser.Tests.ps1` after correcting CRLF.
This commit is contained in:
Steve Lee
2017-09-29 16:28:15 -07:00
committed by Dongbo Wang
parent 8fdd68fbaa
commit 2639cd89ce
86 changed files with 13288 additions and 13288 deletions
+100 -100
View File
@@ -1,100 +1,100 @@
Describe "Serialization Tests" -tags "CI" {
BeforeAll {
$testfileName="SerializationTest.txt"
$testPath = Join-Path $TestDrive $testfileName
$testfile = New-Item $testPath -Force
function SerializeAndDeserialize([PSObject]$inputObject)
{
$xmlSerializer = New-Object System.Xml.Serialization.XmlSerializer($inputObject.GetType())
$stream = [System.IO.StreamWriter]$testPath
$xmlWriter = [System.Xml.XmlWriter]::Create($stream)
$xmlSerializer.Serialize($xmlWriter,$inputObject)
$stream.Close()
$stream = [System.IO.StreamReader]$testPath
$xmlReader = [System.Xml.XmlReader]::Create($stream)
$outputObject = $xmlSerializer.Deserialize($xmlReader)
$stream.Close()
$xmlReader.Dispose()
return $outputObject;
}
enum MyColorFlag
{
RED
BLUE
}
}
AfterAll {
Remove-Item $testPath -Force -ErrorAction SilentlyContinue
}
It 'Test DateTimeUtc serialize and deserialize work as expected.' {
$inputObject = [System.DateTime]::UtcNow;
SerializeAndDeserialize($inputObject) | Should be $inputObject
}
It 'Test DateTime stamps serialize and deserialize work as expected.' {
$objs = [System.DateTime]::MaxValue, [System.DateTime]::MinValue, [System.DateTime]::Today, (new-object System.DateTime), (new-object System.DateTime 123456789)
foreach($inputObject in $objs)
{
SerializeAndDeserialize($inputObject) | Should be $inputObject
}
}
#pending because of "System.Uri cannot be serialized because it does not have a parameterless constructor."
It 'Test system Uri objects serialize and deserialize work as expected.' -Pending:$true {
$uristrings = "http://www.microsoft.com","http://www.microsoft.com:8000","http://www.microsoft.com/index.html","http://www.microsoft.com/default.asp","http://www.microsoft.com/Hello%20World.htm"
foreach($uristring in $uristrings)
{
$inputObject = new-object System.Uri $uristring
SerializeAndDeserialize($inputObject) | Should be $inputObject
}
}
It 'Test a byte array serialize and deserialize work as expected.' {
$objs1 = [byte]0, [byte]1, [byte]2, [byte]3, [byte]255
$objs2 = @()
$objs3 = [byte]128
$objs4 = @()
for($i=0;$i -lt 256;$i++)
{
$objs4 += [byte]$i
}
$objsArray = New-Object System.Collections.ArrayList
$objsArray.Add($objs1)
$objsArray.Add($objs2)
$objsArray.Add($objs3)
$objsArray.Add($objs4)
foreach($inputObject in $objsArray )
{
$outputs = SerializeAndDeserialize($inputObject);
for($i=0;$i -lt $inputObject.Length;$i++)
{
$outputs[$i] | Should be $inputObject[$i]
}
}
}
It 'Test Enum serialize and deserialize work as expected.' {
$inputObject = [MyColorFlag]::RED
SerializeAndDeserialize($inputObject).ToString() | Should be $inputObject.ToString()
}
It 'Test SecureString serialize and deserialize work as expected.' {
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
$inputObject = Convertto-Securestring -String "PowerShellRocks!" -AsPlainText -Force
SerializeAndDeserialize($inputObject).Length | Should be $inputObject.Length
}
It 'Test ScriptProperty object serialize and deserialize work as expected.' {
$versionObject = New-Object PSObject
$versionObject | Add-Member -MemberType NoteProperty -Name TestNote -Value "TestNote"
$versionObject | Add-Member -MemberType ScriptProperty -Name TestScriptProperty -Value { ($this.TestNote) }
SerializeAndDeserialize($versionObject).TestScriptProperty | Should be $versionObject.TestScriptProperty
}
}
Describe "Serialization Tests" -tags "CI" {
BeforeAll {
$testfileName="SerializationTest.txt"
$testPath = Join-Path $TestDrive $testfileName
$testfile = New-Item $testPath -Force
function SerializeAndDeserialize([PSObject]$inputObject)
{
$xmlSerializer = New-Object System.Xml.Serialization.XmlSerializer($inputObject.GetType())
$stream = [System.IO.StreamWriter]$testPath
$xmlWriter = [System.Xml.XmlWriter]::Create($stream)
$xmlSerializer.Serialize($xmlWriter,$inputObject)
$stream.Close()
$stream = [System.IO.StreamReader]$testPath
$xmlReader = [System.Xml.XmlReader]::Create($stream)
$outputObject = $xmlSerializer.Deserialize($xmlReader)
$stream.Close()
$xmlReader.Dispose()
return $outputObject;
}
enum MyColorFlag
{
RED
BLUE
}
}
AfterAll {
Remove-Item $testPath -Force -ErrorAction SilentlyContinue
}
It 'Test DateTimeUtc serialize and deserialize work as expected.' {
$inputObject = [System.DateTime]::UtcNow;
SerializeAndDeserialize($inputObject) | Should be $inputObject
}
It 'Test DateTime stamps serialize and deserialize work as expected.' {
$objs = [System.DateTime]::MaxValue, [System.DateTime]::MinValue, [System.DateTime]::Today, (new-object System.DateTime), (new-object System.DateTime 123456789)
foreach($inputObject in $objs)
{
SerializeAndDeserialize($inputObject) | Should be $inputObject
}
}
#pending because of "System.Uri cannot be serialized because it does not have a parameterless constructor."
It 'Test system Uri objects serialize and deserialize work as expected.' -Pending:$true {
$uristrings = "http://www.microsoft.com","http://www.microsoft.com:8000","http://www.microsoft.com/index.html","http://www.microsoft.com/default.asp","http://www.microsoft.com/Hello%20World.htm"
foreach($uristring in $uristrings)
{
$inputObject = new-object System.Uri $uristring
SerializeAndDeserialize($inputObject) | Should be $inputObject
}
}
It 'Test a byte array serialize and deserialize work as expected.' {
$objs1 = [byte]0, [byte]1, [byte]2, [byte]3, [byte]255
$objs2 = @()
$objs3 = [byte]128
$objs4 = @()
for($i=0;$i -lt 256;$i++)
{
$objs4 += [byte]$i
}
$objsArray = New-Object System.Collections.ArrayList
$objsArray.Add($objs1)
$objsArray.Add($objs2)
$objsArray.Add($objs3)
$objsArray.Add($objs4)
foreach($inputObject in $objsArray )
{
$outputs = SerializeAndDeserialize($inputObject);
for($i=0;$i -lt $inputObject.Length;$i++)
{
$outputs[$i] | Should be $inputObject[$i]
}
}
}
It 'Test Enum serialize and deserialize work as expected.' {
$inputObject = [MyColorFlag]::RED
SerializeAndDeserialize($inputObject).ToString() | Should be $inputObject.ToString()
}
It 'Test SecureString serialize and deserialize work as expected.' {
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")]
$inputObject = Convertto-Securestring -String "PowerShellRocks!" -AsPlainText -Force
SerializeAndDeserialize($inputObject).Length | Should be $inputObject.Length
}
It 'Test ScriptProperty object serialize and deserialize work as expected.' {
$versionObject = New-Object PSObject
$versionObject | Add-Member -MemberType NoteProperty -Name TestNote -Value "TestNote"
$versionObject | Add-Member -MemberType ScriptProperty -Name TestScriptProperty -Value { ($this.TestNote) }
SerializeAndDeserialize($versionObject).TestScriptProperty | Should be $versionObject.TestScriptProperty
}
}
@@ -1,24 +1,24 @@
Describe "Attribute tests" -Tags "CI" {
BeforeEach {
Remove-Item $testdrive/test.ps1 -Force -ErrorAction SilentlyContinue
}
It "<attribute> attribute returns argument error if empty" -TestCases @(
@{Attribute="HelpMessage"},
@{Attribute="HelpMessageBaseName"},
@{Attribute="HelpMessageResourceId"}
) {
param($attribute)
$script = @"
[CmdletBinding()]
Param (
[Parameter($attribute="")]
[String]`$Parameter1
)
Write-Output "Hello"
"@
New-Item -Path $testdrive/test.ps1 -Value $script -ItemType File
{ & $testdrive/test.ps1 } | ShouldBeErrorId "Argument"
}
}
Describe "Attribute tests" -Tags "CI" {
BeforeEach {
Remove-Item $testdrive/test.ps1 -Force -ErrorAction SilentlyContinue
}
It "<attribute> attribute returns argument error if empty" -TestCases @(
@{Attribute="HelpMessage"},
@{Attribute="HelpMessageBaseName"},
@{Attribute="HelpMessageResourceId"}
) {
param($attribute)
$script = @"
[CmdletBinding()]
Param (
[Parameter($attribute="")]
[String]`$Parameter1
)
Write-Output "Hello"
"@
New-Item -Path $testdrive/test.ps1 -Value $script -ItemType File
{ & $testdrive/test.ps1 } | ShouldBeErrorId "Argument"
}
}
File diff suppressed because it is too large Load Diff
+289 -289
View File
@@ -1,289 +1,289 @@
$script:CimClassName = "PSCore_CimTest1"
$script:CimNamespace = "root/default"
$script:moduleDir = Join-Path -Path $PSScriptRoot -ChildPath assets -AdditionalChildPath CimTest
$script:deleteMof = Join-Path -Path $moduleDir -ChildPath DeleteCimTest.mof
$script:createMof = Join-Path -Path $moduleDir -ChildPath CreateCimTest.mof
$CimCmdletArgs = @{
Namespace = ${script:CimNamespace}
ClassName = ${script:CimClassName}
ErrorAction = "SilentlyContinue"
}
$script:ItSkipOrPending = @{}
function Test-CimTestClass {
$null -eq (Get-CimClass @CimCmdletArgs)
}
function Test-CimTestInstance {
$null -eq (Get-CimInstance @CimCmdletArgs)
}
Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows {
BeforeAll {
$skipNotWindows = ! $IsWindows
if ( $skipNotWindows ) {
$script:ItSkipOrPending = @{ Skip = $true }
return
}
# if MofComp does not exist, we shouldn't bother moving forward
# there is a possibility that we could be on Windows, but MofComp
# isn't present, in any event we will mark these tests as skipped
# since the environment won't support loading the test classes
if ( (Get-Command -ea SilentlyContinue Mofcomp.exe) -eq $null ) {
$script:ItSkipOrPending = @{ Skip = $true }
return
}
# start from a clean slate, remove the instances and the
# classes if they exist
if ( Test-CimTestClass ) {
if ( Test-CimTestInstance ) {
Get-CimInstance @CimCmdletArgs | Remove-CimInstance
}
# if there's a failure with mofcomp then we will have trouble
# executing the tests. Keep track of the exit code
$result = MofComp.exe $deleteMof
$script:MofCompReturnCode = $LASTEXITCODE
if ( $script:MofCompReturnCode -ne 0 ) {
return
}
}
# create the class and instances
# and track the exitcode for the compilation of the mof file
# if there's a problem, there's no reason to keep going
$testMof = Get-Content -Path ${script:createmof} -Raw
$currentTimeZone = [System.TimeZoneInfo]::Local
# this date is simply the same one used in the test mof
# the minutes must be padded to 3 digits proceeded by a '+' or '-'
# when east of UTC 0 we must add a '+'
$offsetMinutes = ($currentTimeZone.GetUtcOffset([datetime]::new(2008, 01, 01, 0, 0, 0))).TotalMinutes
$UTCOffset = "{0:+000;-000}" -f $offsetMinutes
$testMof = $testMof.Replace("<UTCOffSet>", $UTCOffset)
Set-Content -Path $testDrive\testmof.mof -Value $testMof
$result = MofComp.exe $testDrive\testmof.mof
$script:MofCompReturnCode = $LASTEXITCODE
if ( $script:MofCompReturnCode -ne 0 ) {
return
}
# now load the cdxml module
if ( Get-Module CimTest ) {
Remove-Module -force CimTest
}
Import-Module -force ${script:ModuleDir}
}
AfterAll {
if ( $skipNotWindows ) {
return
}
if ( get-module CimTest ) {
Remove-Module CimTest -Force
}
$null = MofComp.exe $deleteMof
if ( $LASTEXITCODE -ne 0 ) {
Write-Warning "Could not remove PSCore_CimTest class"
}
}
BeforeEach {
If ( $script:MofCompReturnCode -ne 0 ) {
throw "MofComp.exe failed with exit code $MofCompReturnCode"
}
}
Context "Module level tests" {
It "The CimTest module should have been loaded" @ItSkipOrPending {
$result = Get-Module CimTest
$result.ModuleBase | should be ${script:ModuleDir}
}
It "The CimTest module should have the proper cmdlets" @ItSkipOrPending {
$result = Get-Command -Module CimTest
$result.Count | Should Be 4
($result.Name | sort-object ) -join "," | Should Be "Get-CimTest,New-CimTest,Remove-CimTest,Set-CimTest"
}
}
Context "Get-CimTest cmdlet" {
It "The Get-CimTest cmdlet should return 4 objects" @ItSkipOrPending {
$result = Get-CimTest
$result.Count | should be 4
($result.id |sort-object) -join "," | should be "1,2,3,4"
}
It "The Get-CimTest cmdlet should retrieve an object via id" @ItSkipOrPending {
$result = Get-CimTest -id 1
@($result).Count | should be 1
$result.field1 | Should be "instance 1"
}
It "The Get-CimTest cmdlet should retrieve an object by piped id" @ItSkipOrPending {
$result = 1,2,4 | foreach-object { [pscustomobject]@{ id = $_ } } | Get-CimTest
@($result).Count | should be 3
( $result.id | sort-object ) -join "," | Should be "1,2,4"
}
It "The Get-CimTest cmdlet should retrieve an object by datetime" @ItSkipOrPending {
$result = Get-CimTest -DateTime ([datetime]::new(2008,01,01,0,0,0))
@($result).Count | Should Be 1
$result.field1 | Should Be "instance 1"
}
It "The Get-CimTest cmdlet should return the proper error if the instance does not exist" @ItSkipOrPending {
{ Get-CimTest -ea stop -id "ThisIdDoesNotExist" } | ShouldBeErrorId "CmdletizationQuery_NotFound_Id,Get-CimTest"
}
It "The Get-CimTest cmdlet should work as a job" @ItSkipOrPending {
try {
$job = Get-CimTest -AsJob
$result = $null
# wait up to 10 seconds, then the test will fail
# we need to wait long enough, but not too long
# the time can be adjusted
$null = Wait-Job -Job $job -timeout 10
$result = $job | Receive-Job
$result.Count | should be 4
( $result.id | sort-object ) -join "," | Should be "1,2,3,4"
}
finally {
if ( $job ) {
$job | Remove-Job -force
}
}
}
It "Should be possible to invoke a method on an object returned by Get-CimTest" @ItSkipOrPending {
$result = Get-CimTest | Select-Object -first 1
$result.GetCimSessionInstanceId() | Should BeOfType [guid]
}
}
Context "Remove-CimTest cmdlet" {
BeforeEach {
Get-CimTest | Remove-CimTest
1..4 | Foreach-Object { New-CimInstance -namespace root/default -class PSCore_Test1 -property @{
id = "$_"
field1 = "field $_"
field2 = 10 * $_
}
}
}
It "The Remote-CimTest cmdlet should remove objects by id" @ItSkipOrPending {
Remove-CimTest -id 1
$result = Get-CimTest
$result.Count | should be 3
($result.id |sort-object) -join "," | should be "2,3,4"
}
It "The Remove-CimTest cmdlet should remove piped objects" @ItSkipOrPending {
Get-CimTest -id 2 | Remove-CimTest
$result = Get-CimTest
@($result).Count | should be 3
($result.id |sort-object) -join "," | should be "1,3,4"
}
It "The Remove-CimTest cmdlet should work as a job" @ItSkipOrPending {
try {
$job = Get-CimTest -id 3 | Remove-CimTest -asjob
$result = $null
# wait up to 10 seconds, then the test will fail
# we need to wait long enough, but not too long
# the time can be adjusted
$null = Wait-Job -Job $job -Timeout 10
$result = Get-CimTest
@($result).Count | should be 3
($result.id |sort-object) -join "," | should be "1,2,4"
}
finally {
if ( $job ) {
$job | Remove-Job -force
}
}
}
}
Context "New-CimTest operations" {
It "Should create a new instance" @ItSkipOrPending {
$instanceArgs = @{
id = "telephone"
field1 = "television"
field2 = 0
}
New-CimTest @instanceArgs
$result = Get-CimInstance -namespace root/default -class PSCore_Test1 | Where-Object {$_.id -eq "telephone"}
$result.field2 | should be 0
$result.field1 | Should be $instanceArgs.field1
}
It "Should return the proper error if called with an improper value" @ItSkipOrPending {
$instanceArgs = @{
Id = "error validation"
field1 = "a string"
field2 = "a bad string" # this needs to be an int
}
{ New-CimTest @instanceArgs } | ShouldBeErrorId "ParameterArgumentTransformationError,New-CimTest"
# just make sure that it wasn't added
Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should BeNullOrEmpty
}
It "Should support -whatif" @ItSkipOrPending {
$instanceArgs = @{
Id = "1000"
field1 = "a string"
field2 = 111
Whatif = $true
}
New-CimTest @instanceArgs
Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should BeNullOrEmpty
}
}
Context "Set-CimTest operations" {
It "Should set properties on an instance" @ItSkipOrPending {
$instanceArgs = @{
id = "updateTest1"
field1 = "updatevalue"
field2 = 100
}
$newValues = @{
id = "updateTest1"
field2 = 22
field1 = "newvalue"
}
New-CimTest @instanceArgs
$result = Get-CimTest -id $instanceArgs.id
$result.field2 | should be $instanceArgs.field2
$result.field1 | Should be $instanceArgs.field1
Set-CimTest @newValues
$result = Get-CimTest -id $newValues.id
$result.field1 | Should be $newValues.field1
$result.field2 | should be $newValues.field2
}
It "Should set properties on an instance via pipeline" @ItSkipOrPending {
$instanceArgs = @{
id = "updateTest2"
field1 = "updatevalue"
field2 = 100
}
New-CimTest @instanceArgs
$result = Get-CimTest -id $instanceArgs.id
$result.field2 | should be $instanceArgs.field2
$result.field1 | Should be $instanceArgs.field1
$result.field1 = "yet another value"
$result.field2 = 33
$result | Set-CimTest
$result = Get-CimTest -id $instanceArgs.id
$result.field1 | Should be "yet another value"
$result.field2 | should be 33
}
}
}
$script:CimClassName = "PSCore_CimTest1"
$script:CimNamespace = "root/default"
$script:moduleDir = Join-Path -Path $PSScriptRoot -ChildPath assets -AdditionalChildPath CimTest
$script:deleteMof = Join-Path -Path $moduleDir -ChildPath DeleteCimTest.mof
$script:createMof = Join-Path -Path $moduleDir -ChildPath CreateCimTest.mof
$CimCmdletArgs = @{
Namespace = ${script:CimNamespace}
ClassName = ${script:CimClassName}
ErrorAction = "SilentlyContinue"
}
$script:ItSkipOrPending = @{}
function Test-CimTestClass {
$null -eq (Get-CimClass @CimCmdletArgs)
}
function Test-CimTestInstance {
$null -eq (Get-CimInstance @CimCmdletArgs)
}
Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows {
BeforeAll {
$skipNotWindows = ! $IsWindows
if ( $skipNotWindows ) {
$script:ItSkipOrPending = @{ Skip = $true }
return
}
# if MofComp does not exist, we shouldn't bother moving forward
# there is a possibility that we could be on Windows, but MofComp
# isn't present, in any event we will mark these tests as skipped
# since the environment won't support loading the test classes
if ( (Get-Command -ea SilentlyContinue Mofcomp.exe) -eq $null ) {
$script:ItSkipOrPending = @{ Skip = $true }
return
}
# start from a clean slate, remove the instances and the
# classes if they exist
if ( Test-CimTestClass ) {
if ( Test-CimTestInstance ) {
Get-CimInstance @CimCmdletArgs | Remove-CimInstance
}
# if there's a failure with mofcomp then we will have trouble
# executing the tests. Keep track of the exit code
$result = MofComp.exe $deleteMof
$script:MofCompReturnCode = $LASTEXITCODE
if ( $script:MofCompReturnCode -ne 0 ) {
return
}
}
# create the class and instances
# and track the exitcode for the compilation of the mof file
# if there's a problem, there's no reason to keep going
$testMof = Get-Content -Path ${script:createmof} -Raw
$currentTimeZone = [System.TimeZoneInfo]::Local
# this date is simply the same one used in the test mof
# the minutes must be padded to 3 digits proceeded by a '+' or '-'
# when east of UTC 0 we must add a '+'
$offsetMinutes = ($currentTimeZone.GetUtcOffset([datetime]::new(2008, 01, 01, 0, 0, 0))).TotalMinutes
$UTCOffset = "{0:+000;-000}" -f $offsetMinutes
$testMof = $testMof.Replace("<UTCOffSet>", $UTCOffset)
Set-Content -Path $testDrive\testmof.mof -Value $testMof
$result = MofComp.exe $testDrive\testmof.mof
$script:MofCompReturnCode = $LASTEXITCODE
if ( $script:MofCompReturnCode -ne 0 ) {
return
}
# now load the cdxml module
if ( Get-Module CimTest ) {
Remove-Module -force CimTest
}
Import-Module -force ${script:ModuleDir}
}
AfterAll {
if ( $skipNotWindows ) {
return
}
if ( get-module CimTest ) {
Remove-Module CimTest -Force
}
$null = MofComp.exe $deleteMof
if ( $LASTEXITCODE -ne 0 ) {
Write-Warning "Could not remove PSCore_CimTest class"
}
}
BeforeEach {
If ( $script:MofCompReturnCode -ne 0 ) {
throw "MofComp.exe failed with exit code $MofCompReturnCode"
}
}
Context "Module level tests" {
It "The CimTest module should have been loaded" @ItSkipOrPending {
$result = Get-Module CimTest
$result.ModuleBase | should be ${script:ModuleDir}
}
It "The CimTest module should have the proper cmdlets" @ItSkipOrPending {
$result = Get-Command -Module CimTest
$result.Count | Should Be 4
($result.Name | sort-object ) -join "," | Should Be "Get-CimTest,New-CimTest,Remove-CimTest,Set-CimTest"
}
}
Context "Get-CimTest cmdlet" {
It "The Get-CimTest cmdlet should return 4 objects" @ItSkipOrPending {
$result = Get-CimTest
$result.Count | should be 4
($result.id |sort-object) -join "," | should be "1,2,3,4"
}
It "The Get-CimTest cmdlet should retrieve an object via id" @ItSkipOrPending {
$result = Get-CimTest -id 1
@($result).Count | should be 1
$result.field1 | Should be "instance 1"
}
It "The Get-CimTest cmdlet should retrieve an object by piped id" @ItSkipOrPending {
$result = 1,2,4 | foreach-object { [pscustomobject]@{ id = $_ } } | Get-CimTest
@($result).Count | should be 3
( $result.id | sort-object ) -join "," | Should be "1,2,4"
}
It "The Get-CimTest cmdlet should retrieve an object by datetime" @ItSkipOrPending {
$result = Get-CimTest -DateTime ([datetime]::new(2008,01,01,0,0,0))
@($result).Count | Should Be 1
$result.field1 | Should Be "instance 1"
}
It "The Get-CimTest cmdlet should return the proper error if the instance does not exist" @ItSkipOrPending {
{ Get-CimTest -ea stop -id "ThisIdDoesNotExist" } | ShouldBeErrorId "CmdletizationQuery_NotFound_Id,Get-CimTest"
}
It "The Get-CimTest cmdlet should work as a job" @ItSkipOrPending {
try {
$job = Get-CimTest -AsJob
$result = $null
# wait up to 10 seconds, then the test will fail
# we need to wait long enough, but not too long
# the time can be adjusted
$null = Wait-Job -Job $job -timeout 10
$result = $job | Receive-Job
$result.Count | should be 4
( $result.id | sort-object ) -join "," | Should be "1,2,3,4"
}
finally {
if ( $job ) {
$job | Remove-Job -force
}
}
}
It "Should be possible to invoke a method on an object returned by Get-CimTest" @ItSkipOrPending {
$result = Get-CimTest | Select-Object -first 1
$result.GetCimSessionInstanceId() | Should BeOfType [guid]
}
}
Context "Remove-CimTest cmdlet" {
BeforeEach {
Get-CimTest | Remove-CimTest
1..4 | Foreach-Object { New-CimInstance -namespace root/default -class PSCore_Test1 -property @{
id = "$_"
field1 = "field $_"
field2 = 10 * $_
}
}
}
It "The Remote-CimTest cmdlet should remove objects by id" @ItSkipOrPending {
Remove-CimTest -id 1
$result = Get-CimTest
$result.Count | should be 3
($result.id |sort-object) -join "," | should be "2,3,4"
}
It "The Remove-CimTest cmdlet should remove piped objects" @ItSkipOrPending {
Get-CimTest -id 2 | Remove-CimTest
$result = Get-CimTest
@($result).Count | should be 3
($result.id |sort-object) -join "," | should be "1,3,4"
}
It "The Remove-CimTest cmdlet should work as a job" @ItSkipOrPending {
try {
$job = Get-CimTest -id 3 | Remove-CimTest -asjob
$result = $null
# wait up to 10 seconds, then the test will fail
# we need to wait long enough, but not too long
# the time can be adjusted
$null = Wait-Job -Job $job -Timeout 10
$result = Get-CimTest
@($result).Count | should be 3
($result.id |sort-object) -join "," | should be "1,2,4"
}
finally {
if ( $job ) {
$job | Remove-Job -force
}
}
}
}
Context "New-CimTest operations" {
It "Should create a new instance" @ItSkipOrPending {
$instanceArgs = @{
id = "telephone"
field1 = "television"
field2 = 0
}
New-CimTest @instanceArgs
$result = Get-CimInstance -namespace root/default -class PSCore_Test1 | Where-Object {$_.id -eq "telephone"}
$result.field2 | should be 0
$result.field1 | Should be $instanceArgs.field1
}
It "Should return the proper error if called with an improper value" @ItSkipOrPending {
$instanceArgs = @{
Id = "error validation"
field1 = "a string"
field2 = "a bad string" # this needs to be an int
}
{ New-CimTest @instanceArgs } | ShouldBeErrorId "ParameterArgumentTransformationError,New-CimTest"
# just make sure that it wasn't added
Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should BeNullOrEmpty
}
It "Should support -whatif" @ItSkipOrPending {
$instanceArgs = @{
Id = "1000"
field1 = "a string"
field2 = 111
Whatif = $true
}
New-CimTest @instanceArgs
Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should BeNullOrEmpty
}
}
Context "Set-CimTest operations" {
It "Should set properties on an instance" @ItSkipOrPending {
$instanceArgs = @{
id = "updateTest1"
field1 = "updatevalue"
field2 = 100
}
$newValues = @{
id = "updateTest1"
field2 = 22
field1 = "newvalue"
}
New-CimTest @instanceArgs
$result = Get-CimTest -id $instanceArgs.id
$result.field2 | should be $instanceArgs.field2
$result.field1 | Should be $instanceArgs.field1
Set-CimTest @newValues
$result = Get-CimTest -id $newValues.id
$result.field1 | Should be $newValues.field1
$result.field2 | should be $newValues.field2
}
It "Should set properties on an instance via pipeline" @ItSkipOrPending {
$instanceArgs = @{
id = "updateTest2"
field1 = "updatevalue"
field2 = 100
}
New-CimTest @instanceArgs
$result = Get-CimTest -id $instanceArgs.id
$result.field2 | should be $instanceArgs.field2
$result.field1 | Should be $instanceArgs.field1
$result.field1 = "yet another value"
$result.field2 = 33
$result | Set-CimTest
$result = Get-CimTest -id $instanceArgs.id
$result.field1 | Should be "yet another value"
$result.field2 | should be 33
}
}
}
@@ -1,128 +1,128 @@
<PowerShellMetadata xmlns="http://schemas.microsoft.com/cmdlets-over-objects/2009/11">
<Class ClassName="ROOT/default/PSCore_Test1">
<Version>1.0.0.0</Version>
<DefaultNoun>CimTest</DefaultNoun>
<InstanceCmdlets>
<!--
//
// Get-CimTest
//
-->
<GetCmdletParameters DefaultCmdletParameterSet="Id">
<QueryableProperties>
<Property PropertyName="Id">
<Type PSType="System.String" />
<RegularQuery>
<CmdletParameterMetadata ValueFromPipelineByPropertyName="true" CmdletParameterSets="Id" />
</RegularQuery>
</Property>
<Property PropertyName="DateTime">
<Type PSType="System.DateTime" />
<RegularQuery>
<CmdletParameterMetadata PSName="DateTime" ValueFromPipelineByPropertyName="false" CmdletParameterSets="DateTime" />
</RegularQuery>
</Property>
</QueryableProperties>
</GetCmdletParameters>
<Cmdlet>
<CmdletMetadata Verb="Remove" ConfirmImpact="Medium" />
<Method MethodName="cim:DeleteInstance">
<Parameters>
<Parameter ParameterName="cim:operationOption:SourceCaller" DefaultValue="Microsoft.PowerShell">
<Type PSType="System.String" />
</Parameter>
</Parameters>
</Method>
<GetCmdletParameters DefaultCmdletParameterSet="Id">
<QueryableProperties>
<Property PropertyName="Id">
<Type PSType="System.String" />
<RegularQuery>
<CmdletParameterMetadata Position="0" IsMandatory="true" ValueFromPipelineByPropertyName="true" CmdletParameterSets="Id" />
</RegularQuery>
</Property>
</QueryableProperties>
</GetCmdletParameters>
</Cmdlet>
<!-- Set-CimTest -->
<Cmdlet>
<CmdletMetadata Verb="Set" ConfirmImpact="Medium" HelpUri="http://go.microsoft.com/fwlink/?LinkID=241963" Aliases="scimt"/>
<Method MethodName="cim:ModifyInstance">
<Parameters>
<Parameter ParameterName="field1">
<Type PSType="string" />
<CmdletParameterMetadata ValueFromPipelineByPropertyName="true">
<AllowEmptyString />
<ValidateNotNull />
</CmdletParameterMetadata>
</Parameter>
<Parameter ParameterName="field2">
<Type PSType="Uint32" />
<CmdletParameterMetadata ValueFromPipelineByPropertyName="true">
<ValidateNotNull />
<ValidateNotNullOrEmpty />
</CmdletParameterMetadata>
</Parameter>
</Parameters>
</Method>
<GetCmdletParameters>
<QueryableProperties>
<Property PropertyName="Id">
<Type PSType="string" />
<RegularQuery AllowGlobbing="false">
<CmdletParameterMetadata IsMandatory="true" Position="1" ValueFromPipelineByPropertyName="true" CmdletParameterSets="Query">
<ValidateNotNull />
<ValidateNotNullOrEmpty />
</CmdletParameterMetadata>
</RegularQuery>
</Property>
</QueryableProperties>
</GetCmdletParameters>
</Cmdlet>
</InstanceCmdlets>
<StaticCmdlets>
<Cmdlet>
<CmdletMetadata Verb="New" ConfirmImpact="Medium" />
<Method MethodName="cim:CreateInstance">
<Parameters>
<Parameter ParameterName="Id">
<Type PSType="string" />
<CmdletParameterMetadata PSName="Id" />
</Parameter>
<Parameter ParameterName="field1">
<Type PSType="string" />
<CmdletParameterMetadata PSName="field1" />
</Parameter>
<Parameter ParameterName="field2">
<Type PSType="int32" />
<CmdletParameterMetadata PSName="field2" />
</Parameter>
</Parameters>
</Method>
</Cmdlet>
</StaticCmdlets>
<CmdletAdapterPrivateData>
<Data Name="ClientSideShouldProcess" />
</CmdletAdapterPrivateData>
</Class>
<Enums>
<Enum EnumName="CimTest.field2enum" UnderlyingType="System.Int32">
<Value Name="Default" Value="0" />
<Value Name="Value1" Value="1" />
<Value Name="Value2" Value="2" />
<Value Name="Value3" Value="3" />
<Value Name="Value4" Value="4" />
<Value Name="Value5" Value="5" />
<Value Name="Value6" Value="6" />
</Enum>
</Enums>
</PowerShellMetadata>
<PowerShellMetadata xmlns="http://schemas.microsoft.com/cmdlets-over-objects/2009/11">
<Class ClassName="ROOT/default/PSCore_Test1">
<Version>1.0.0.0</Version>
<DefaultNoun>CimTest</DefaultNoun>
<InstanceCmdlets>
<!--
//
// Get-CimTest
//
-->
<GetCmdletParameters DefaultCmdletParameterSet="Id">
<QueryableProperties>
<Property PropertyName="Id">
<Type PSType="System.String" />
<RegularQuery>
<CmdletParameterMetadata ValueFromPipelineByPropertyName="true" CmdletParameterSets="Id" />
</RegularQuery>
</Property>
<Property PropertyName="DateTime">
<Type PSType="System.DateTime" />
<RegularQuery>
<CmdletParameterMetadata PSName="DateTime" ValueFromPipelineByPropertyName="false" CmdletParameterSets="DateTime" />
</RegularQuery>
</Property>
</QueryableProperties>
</GetCmdletParameters>
<Cmdlet>
<CmdletMetadata Verb="Remove" ConfirmImpact="Medium" />
<Method MethodName="cim:DeleteInstance">
<Parameters>
<Parameter ParameterName="cim:operationOption:SourceCaller" DefaultValue="Microsoft.PowerShell">
<Type PSType="System.String" />
</Parameter>
</Parameters>
</Method>
<GetCmdletParameters DefaultCmdletParameterSet="Id">
<QueryableProperties>
<Property PropertyName="Id">
<Type PSType="System.String" />
<RegularQuery>
<CmdletParameterMetadata Position="0" IsMandatory="true" ValueFromPipelineByPropertyName="true" CmdletParameterSets="Id" />
</RegularQuery>
</Property>
</QueryableProperties>
</GetCmdletParameters>
</Cmdlet>
<!-- Set-CimTest -->
<Cmdlet>
<CmdletMetadata Verb="Set" ConfirmImpact="Medium" HelpUri="http://go.microsoft.com/fwlink/?LinkID=241963" Aliases="scimt"/>
<Method MethodName="cim:ModifyInstance">
<Parameters>
<Parameter ParameterName="field1">
<Type PSType="string" />
<CmdletParameterMetadata ValueFromPipelineByPropertyName="true">
<AllowEmptyString />
<ValidateNotNull />
</CmdletParameterMetadata>
</Parameter>
<Parameter ParameterName="field2">
<Type PSType="Uint32" />
<CmdletParameterMetadata ValueFromPipelineByPropertyName="true">
<ValidateNotNull />
<ValidateNotNullOrEmpty />
</CmdletParameterMetadata>
</Parameter>
</Parameters>
</Method>
<GetCmdletParameters>
<QueryableProperties>
<Property PropertyName="Id">
<Type PSType="string" />
<RegularQuery AllowGlobbing="false">
<CmdletParameterMetadata IsMandatory="true" Position="1" ValueFromPipelineByPropertyName="true" CmdletParameterSets="Query">
<ValidateNotNull />
<ValidateNotNullOrEmpty />
</CmdletParameterMetadata>
</RegularQuery>
</Property>
</QueryableProperties>
</GetCmdletParameters>
</Cmdlet>
</InstanceCmdlets>
<StaticCmdlets>
<Cmdlet>
<CmdletMetadata Verb="New" ConfirmImpact="Medium" />
<Method MethodName="cim:CreateInstance">
<Parameters>
<Parameter ParameterName="Id">
<Type PSType="string" />
<CmdletParameterMetadata PSName="Id" />
</Parameter>
<Parameter ParameterName="field1">
<Type PSType="string" />
<CmdletParameterMetadata PSName="field1" />
</Parameter>
<Parameter ParameterName="field2">
<Type PSType="int32" />
<CmdletParameterMetadata PSName="field2" />
</Parameter>
</Parameters>
</Method>
</Cmdlet>
</StaticCmdlets>
<CmdletAdapterPrivateData>
<Data Name="ClientSideShouldProcess" />
</CmdletAdapterPrivateData>
</Class>
<Enums>
<Enum EnumName="CimTest.field2enum" UnderlyingType="System.Int32">
<Value Name="Default" Value="0" />
<Value Name="Value1" Value="1" />
<Value Name="Value2" Value="2" />
<Value Name="Value3" Value="3" />
<Value Name="Value4" Value="4" />
<Value Name="Value5" Value="5" />
<Value Name="Value6" Value="6" />
</Enum>
</Enums>
</PowerShellMetadata>
@@ -1,66 +1,66 @@
class PSCore_subclass
{
[key] string id;
string subfield1;
sint32 subfield2;
};
instance of PSCore_subclass
{
id = "s1";
subfield1 = "sub thing";
subfield2 = 100;
};
[HasClassRefs, Association]
class PSCore_Association
{
[key, classref{ "PSCore_Test1", "PSCore_Test2" }]
object ref ep1;
[key] object ref ep2;
};
class PSCore_Test2
{
[key] string id;
string field1;
sint32 field2;
};
class PSCore_Test1
{
[key] string id;
string field1;
sint32 field2;
datetime datetime;
PSCore_subclass subclass;
};
instance of PSCore_Test1
{
id = "1";
field1 = "instance 1";
field2 = -1;
datetime = "20080101000000.000000<UTCOffSet>";
subclass = instance of PSCore_subclass{Id="10";subfield1="yup";subfield2=200;};
};
instance of PSCore_Test1
{
id = "2";
field1 = "instance 2";
field2 = -2;
};
instance of PSCore_Test1
{
id = "3";
field1 = "instance 3";
field2 = -3;
};
instance of PSCore_Test1
{
id = "4";
field1 = "instance 4";
field2 = -4;
};
class PSCore_subclass
{
[key] string id;
string subfield1;
sint32 subfield2;
};
instance of PSCore_subclass
{
id = "s1";
subfield1 = "sub thing";
subfield2 = 100;
};
[HasClassRefs, Association]
class PSCore_Association
{
[key, classref{ "PSCore_Test1", "PSCore_Test2" }]
object ref ep1;
[key] object ref ep2;
};
class PSCore_Test2
{
[key] string id;
string field1;
sint32 field2;
};
class PSCore_Test1
{
[key] string id;
string field1;
sint32 field2;
datetime datetime;
PSCore_subclass subclass;
};
instance of PSCore_Test1
{
id = "1";
field1 = "instance 1";
field2 = -1;
datetime = "20080101000000.000000<UTCOffSet>";
subclass = instance of PSCore_subclass{Id="10";subfield1="yup";subfield2=200;};
};
instance of PSCore_Test1
{
id = "2";
field1 = "instance 2";
field2 = -2;
};
instance of PSCore_Test1
{
id = "3";
field1 = "instance 3";
field2 = -3;
};
instance of PSCore_Test1
{
id = "4";
field1 = "instance 4";
field2 = -4;
};
@@ -1,5 +1,5 @@
#pragma namespace ("\\\\.\\root\\default")
#pragma deleteclass("PSCore_Test1", NOFAIL)
#pragma deleteclass("PSCore_Test2", NOFAIL)
#pragma deleteclass("PSCore_subclass", NOFAIL)
#pragma deleteclass("PSCore_Association", NOFAIL)
#pragma namespace ("\\\\.\\root\\default")
#pragma deleteclass("PSCore_Test1", NOFAIL)
#pragma deleteclass("PSCore_Test2", NOFAIL)
#pragma deleteclass("PSCore_subclass", NOFAIL)
#pragma deleteclass("PSCore_Association", NOFAIL)
+201 -201
View File
@@ -1,201 +1,201 @@
Describe "Adapter Tests" -tags "CI" {
BeforeAll {
$pso = [System.Diagnostics.Process]::GetCurrentProcess()
$processName = $pso.Name
if(-not ('TestCodeMethodClass' -as "type"))
{
class TestCodeMethodClass {
static [int] TestCodeMethod([PSObject] $target, [int] $i)
{
return 1;
}
}
}
$psmemberset = new-object System.Management.Automation.PSMemberSet 'setname1'
$psmemberset | Add-Member -MemberType NoteProperty -Name NoteName -Value 1
$testmethod = [TestCodeMethodClass].GetMethod("TestCodeMethod")
$psmemberset | Add-Member -MemberType CodeMethod -Name TestCodeMethod -Value $testmethod
$document = new-object System.Xml.XmlDocument
$document.LoadXml("<book ISBN='12345'><title>Pride And Prejudice</title><price>19.95</price></book>")
$doc = $document.DocumentElement
}
It "can get a Dotnet parameterized property" {
$col = $pso.psobject.Properties.Match("*")
$prop = $col.psobject.Members["Item"]
$prop | Should Not BeNullOrEmpty
$prop.IsGettable | Should be $true
$prop.IsSettable | Should be $false
$prop.TypeNameOfValue | Should be "System.Management.Automation.PSPropertyInfo"
$prop.Invoke("ProcessName").Value | Should be $processName
}
It "can get a property" {
$pso.psobject.Properties["ProcessName"] | should Not BeNullOrEmpty
}
It "Can access all properties" {
$props = $pso.psobject.Properties.Match("*")
$props | should Not BeNullOrEmpty
$props["ProcessName"].Value |Should be $processName
}
It "Can invoke a method" {
$method = $pso.psobject.Methods["ToString"]
$method.Invoke() | should be ($pso.ToString())
}
It "Access a Method via MemberSet adapter" {
$prop = $psmemberset.psobject.Members["TestCodeMethod"]
$prop.Invoke(2) | Should be 1
}
It "Access misc properties via MemberSet adapter" {
$prop = $psmemberset.psobject.Properties["NoteName"]
$prop | Should Not BeNullOrEmpty
$prop.IsGettable | Should be $true
$prop.IsSettable | Should be $true
$prop.TypeNameOfValue | Should be "System.Int32"
}
It "Access all the properties via XmlAdapter" {
$col = $doc.psobject.Properties.Match("*")
$col.Count | Should Not Be 0
$prop = $col["price"]
$prop | Should Not BeNullOrEmpty
}
It "Access all the properties via XmlAdapter" {
$prop = $doc.psobject.Properties["price"]
$prop.Value | Should Be "19.95"
$prop.IsGettable | Should Not BeNullOrEmpty
$prop.IsSettable | Should Not BeNullOrEmpty
$prop.TypeNameOfValue | Should be "System.String"
}
It "Call to string on a XmlNode object" {
$val = $doc.ToString()
$val | Should Be "book"
}
It "Calls CodeMethod with void result" {
class TestCodeMethodInvokationWithVoidReturn {
[int] $CallCounter
static [int] IntMethodCM([PSObject] $self) {
return $self.CallCounter
}
static [void] VoidMethodCM([PSObject] $self) {
$self.CallCounter++
}
static [Reflection.MethodInfo] GetMethodInfo([string] $name) {
return [TestCodeMethodInvokationWithVoidReturn].GetMethod($name)
}
}
Update-TypeData -Force -TypeName TestCodeMethodInvokationWithVoidReturn -MemberType CodeMethod -MemberName IntMethod -Value ([TestCodeMethodInvokationWithVoidReturn]::GetMethodInfo('IntMethodCM'))
Update-TypeData -Force -TypeName TestCodeMethodInvokationWithVoidReturn -MemberType CodeMethod -MemberName VoidMethod -Value ([TestCodeMethodInvokationWithVoidReturn]::GetMethodInfo('VoidMethodCM'))
try {
$o = [TestCodeMethodInvokationWithVoidReturn]::new()
$o.CallCounter | Should Be 0
$o.VoidMethod()
$o.CallCounter | Should be 1
$o.IntMethod() | Should be 1
}
finally {
Remove-TypeData TestCodeMethodInvokationWithVoidReturn
}
}
}
Describe "Adapter XML Tests" -tags "CI" {
BeforeAll {
[xml]$x = "<root><data/></root>"
$testCases =
@{ rval = @{testprop = 1}; value = 'a hash (psobject)' },
@{ rval = $null; value = 'a null (codemethod)' },
@{ rval = 1; value = 'a int (codemethod)' },
@{ rval = "teststring"; value = 'a string (codemethod)' },
@{ rval = @("teststring1", "teststring2"); value = 'a string array (codemethod)' },
@{ rval = @(1,2); value = 'a int array (codemethod)' },
@{ rval = [PSObject]::AsPSObject(1); value = 'a int (psobject wrapping)' },
@{ rval = [PSObject]::AsPSObject("teststring"); value = 'a string (psobject wrapping)' },
@{ rval = [PSObject]::AsPSObject([psobject]@("teststring1", "teststring2")); value = 'a string array (psobject wrapping)' },
@{ rval = [PSObject]::AsPSObject(@(1,2)); value = 'int array (psobject wrapping)' }
}
Context "Can set XML node property to non-string object" {
It "rval is <value>" -TestCases $testCases {
# rval will be implicitly converted to 'string' type
param($rval)
{
{ $x.root.data = $rval } | Should Not Throw
$x.root.data | Should Be [System.Management.Automation.LanguagePrimitives]::ConvertTo($rval, [string])
}
}
}
}
Describe "DataRow and DataRowView Adapter tests" -tags "CI" {
BeforeAll {
## Define the DataTable schema
$dataTable = [System.Data.DataTable]::new("inputs")
$dataTable.Locale = [cultureinfo]::InvariantCulture
$dataTable.Columns.Add("Id", [int]) > $null
$dataTable.Columns.Add("FirstName", [string]) > $null
$dataTable.Columns.Add("LastName", [string]) > $null
$dataTable.Columns.Add("YearsInMS", [int]) > $null
## Add data entries
$dataTable.Rows.Add(@(1, "joseph", "smith", 15)) > $null
$dataTable.Rows.Add(@(2, "paul", "smith", 15)) > $null
$dataTable.Rows.Add(@(3, "mary jo", "soe", 5)) > $null
$dataTable.Rows.Add(@(4, "edmund`todd `n", "bush", 9)) > $null
}
Context "DataRow Adapter tests" {
It "Should be able to access data columns" {
$row = $dataTable.Rows[0]
$row.Id | Should Be 1
$row.FirstName | Should Be "joseph"
$row.LastName | Should Be "smith"
$row.YearsInMS | Should Be 15
}
It "DataTable should be enumerable in PowerShell" {
## Get the third entry in the data table
$row = $dataTable | Select-Object -Skip 2 -First 1
$row.Id | Should Be 3
$row.FirstName | Should Be "mary jo"
$row.LastName | Should Be "soe"
$row.YearsInMS | Should Be 5
}
}
Context "DataRowView Adapter tests" {
It "Should be able to access data columns" {
$rowView = $dataTable.DefaultView[1]
$rowView.Id | Should Be 2
$rowView.FirstName | Should Be "paul"
$rowView.LastName | Should Be "smith"
$rowView.YearsInMS | Should Be 15
}
It "DataView should be enumerable" {
$rowView = $dataTable.DefaultView | Select-Object -Last 1
$rowView.Id | Should Be 4
$rowView.FirstName | Should Be "edmund`todd `n"
$rowView.LastName | Should Be "bush"
$rowView.YearsInMS | Should Be 9
}
}
}
Describe "Adapter Tests" -tags "CI" {
BeforeAll {
$pso = [System.Diagnostics.Process]::GetCurrentProcess()
$processName = $pso.Name
if(-not ('TestCodeMethodClass' -as "type"))
{
class TestCodeMethodClass {
static [int] TestCodeMethod([PSObject] $target, [int] $i)
{
return 1;
}
}
}
$psmemberset = new-object System.Management.Automation.PSMemberSet 'setname1'
$psmemberset | Add-Member -MemberType NoteProperty -Name NoteName -Value 1
$testmethod = [TestCodeMethodClass].GetMethod("TestCodeMethod")
$psmemberset | Add-Member -MemberType CodeMethod -Name TestCodeMethod -Value $testmethod
$document = new-object System.Xml.XmlDocument
$document.LoadXml("<book ISBN='12345'><title>Pride And Prejudice</title><price>19.95</price></book>")
$doc = $document.DocumentElement
}
It "can get a Dotnet parameterized property" {
$col = $pso.psobject.Properties.Match("*")
$prop = $col.psobject.Members["Item"]
$prop | Should Not BeNullOrEmpty
$prop.IsGettable | Should be $true
$prop.IsSettable | Should be $false
$prop.TypeNameOfValue | Should be "System.Management.Automation.PSPropertyInfo"
$prop.Invoke("ProcessName").Value | Should be $processName
}
It "can get a property" {
$pso.psobject.Properties["ProcessName"] | should Not BeNullOrEmpty
}
It "Can access all properties" {
$props = $pso.psobject.Properties.Match("*")
$props | should Not BeNullOrEmpty
$props["ProcessName"].Value |Should be $processName
}
It "Can invoke a method" {
$method = $pso.psobject.Methods["ToString"]
$method.Invoke() | should be ($pso.ToString())
}
It "Access a Method via MemberSet adapter" {
$prop = $psmemberset.psobject.Members["TestCodeMethod"]
$prop.Invoke(2) | Should be 1
}
It "Access misc properties via MemberSet adapter" {
$prop = $psmemberset.psobject.Properties["NoteName"]
$prop | Should Not BeNullOrEmpty
$prop.IsGettable | Should be $true
$prop.IsSettable | Should be $true
$prop.TypeNameOfValue | Should be "System.Int32"
}
It "Access all the properties via XmlAdapter" {
$col = $doc.psobject.Properties.Match("*")
$col.Count | Should Not Be 0
$prop = $col["price"]
$prop | Should Not BeNullOrEmpty
}
It "Access all the properties via XmlAdapter" {
$prop = $doc.psobject.Properties["price"]
$prop.Value | Should Be "19.95"
$prop.IsGettable | Should Not BeNullOrEmpty
$prop.IsSettable | Should Not BeNullOrEmpty
$prop.TypeNameOfValue | Should be "System.String"
}
It "Call to string on a XmlNode object" {
$val = $doc.ToString()
$val | Should Be "book"
}
It "Calls CodeMethod with void result" {
class TestCodeMethodInvokationWithVoidReturn {
[int] $CallCounter
static [int] IntMethodCM([PSObject] $self) {
return $self.CallCounter
}
static [void] VoidMethodCM([PSObject] $self) {
$self.CallCounter++
}
static [Reflection.MethodInfo] GetMethodInfo([string] $name) {
return [TestCodeMethodInvokationWithVoidReturn].GetMethod($name)
}
}
Update-TypeData -Force -TypeName TestCodeMethodInvokationWithVoidReturn -MemberType CodeMethod -MemberName IntMethod -Value ([TestCodeMethodInvokationWithVoidReturn]::GetMethodInfo('IntMethodCM'))
Update-TypeData -Force -TypeName TestCodeMethodInvokationWithVoidReturn -MemberType CodeMethod -MemberName VoidMethod -Value ([TestCodeMethodInvokationWithVoidReturn]::GetMethodInfo('VoidMethodCM'))
try {
$o = [TestCodeMethodInvokationWithVoidReturn]::new()
$o.CallCounter | Should Be 0
$o.VoidMethod()
$o.CallCounter | Should be 1
$o.IntMethod() | Should be 1
}
finally {
Remove-TypeData TestCodeMethodInvokationWithVoidReturn
}
}
}
Describe "Adapter XML Tests" -tags "CI" {
BeforeAll {
[xml]$x = "<root><data/></root>"
$testCases =
@{ rval = @{testprop = 1}; value = 'a hash (psobject)' },
@{ rval = $null; value = 'a null (codemethod)' },
@{ rval = 1; value = 'a int (codemethod)' },
@{ rval = "teststring"; value = 'a string (codemethod)' },
@{ rval = @("teststring1", "teststring2"); value = 'a string array (codemethod)' },
@{ rval = @(1,2); value = 'a int array (codemethod)' },
@{ rval = [PSObject]::AsPSObject(1); value = 'a int (psobject wrapping)' },
@{ rval = [PSObject]::AsPSObject("teststring"); value = 'a string (psobject wrapping)' },
@{ rval = [PSObject]::AsPSObject([psobject]@("teststring1", "teststring2")); value = 'a string array (psobject wrapping)' },
@{ rval = [PSObject]::AsPSObject(@(1,2)); value = 'int array (psobject wrapping)' }
}
Context "Can set XML node property to non-string object" {
It "rval is <value>" -TestCases $testCases {
# rval will be implicitly converted to 'string' type
param($rval)
{
{ $x.root.data = $rval } | Should Not Throw
$x.root.data | Should Be [System.Management.Automation.LanguagePrimitives]::ConvertTo($rval, [string])
}
}
}
}
Describe "DataRow and DataRowView Adapter tests" -tags "CI" {
BeforeAll {
## Define the DataTable schema
$dataTable = [System.Data.DataTable]::new("inputs")
$dataTable.Locale = [cultureinfo]::InvariantCulture
$dataTable.Columns.Add("Id", [int]) > $null
$dataTable.Columns.Add("FirstName", [string]) > $null
$dataTable.Columns.Add("LastName", [string]) > $null
$dataTable.Columns.Add("YearsInMS", [int]) > $null
## Add data entries
$dataTable.Rows.Add(@(1, "joseph", "smith", 15)) > $null
$dataTable.Rows.Add(@(2, "paul", "smith", 15)) > $null
$dataTable.Rows.Add(@(3, "mary jo", "soe", 5)) > $null
$dataTable.Rows.Add(@(4, "edmund`todd `n", "bush", 9)) > $null
}
Context "DataRow Adapter tests" {
It "Should be able to access data columns" {
$row = $dataTable.Rows[0]
$row.Id | Should Be 1
$row.FirstName | Should Be "joseph"
$row.LastName | Should Be "smith"
$row.YearsInMS | Should Be 15
}
It "DataTable should be enumerable in PowerShell" {
## Get the third entry in the data table
$row = $dataTable | Select-Object -Skip 2 -First 1
$row.Id | Should Be 3
$row.FirstName | Should Be "mary jo"
$row.LastName | Should Be "soe"
$row.YearsInMS | Should Be 5
}
}
Context "DataRowView Adapter tests" {
It "Should be able to access data columns" {
$rowView = $dataTable.DefaultView[1]
$rowView.Id | Should Be 2
$rowView.FirstName | Should Be "paul"
$rowView.LastName | Should Be "smith"
$rowView.YearsInMS | Should Be 15
}
It "DataView should be enumerable" {
$rowView = $dataTable.DefaultView | Select-Object -Last 1
$rowView.Id | Should Be 4
$rowView.FirstName | Should Be "edmund`todd `n"
$rowView.LastName | Should Be "bush"
$rowView.YearsInMS | Should Be 9
}
}
}
@@ -31,17 +31,17 @@ Describe "New-ModuleManifest tests" -tags "CI" {
$module.PrivateData.PSData.ProjectUri | Should BeExactly $absoluteUri
}
function TestNewModuleManifestEncoding {
param ([byte[]]$expected)
function TestNewModuleManifestEncoding {
param ([byte[]]$expected)
New-ModuleManifest -Path $testModulePath
(Get-Content -Encoding Byte -Path $testModulePath -TotalCount $expected.Length) -join ',' | Should Be ($expected -join ',')
(Get-Content -Encoding Byte -Path $testModulePath -TotalCount $expected.Length) -join ',' | Should Be ($expected -join ',')
}
It "Verify module manifest encoding" {
# verify first line of the manifest:
# on Windows platforms - 3 characters - '#' '\r' '\n' - in UTF-16 with BOM - this should be @(255,254,35,0,13,0,10,0)
# on non-Windows platforms - 2 characters - '#' '\n' - in UTF-8 no BOM - this should be @(35,10)
# verify first line of the manifest:
# on Windows platforms - 3 characters - '#' '\r' '\n' - in UTF-16 with BOM - this should be @(255,254,35,0,13,0,10,0)
# on non-Windows platforms - 2 characters - '#' '\n' - in UTF-8 no BOM - this should be @(35,10)
TestNewModuleManifestEncoding -expected $ExpectedManifestBytes
}
@@ -18,25 +18,25 @@
"function TestModuleFunction{'Hello from TestModuleFunction'}" | Out-File $nestedModuleFilePath
}
$testCases = @(
@{ SubModulePath = "$submoduleName" }
@{ SubModulePath = "$submoduleName\$submoduleName" }
@{ SubModulePath = "$submoduleName/$submoduleName" }
@{ SubModulePath = "$submoduleName\$submoduleFileName" }
@{ SubModulePath = "$submoduleName/$submoduleFileName" }
@{ SubModulePath = ".\$submoduleName" }
@{ SubModulePath = ".\$submoduleName\$submoduleName" }
@{ SubModulePath = ".\$submoduleName/$submoduleName" }
@{ SubModulePath = ".\$submoduleName\$submoduleFileName" }
@{ SubModulePath = ".\$submoduleName/$submoduleFileName" }
@{ SubModulePath = "./$submoduleName" }
@{ SubModulePath = "./$submoduleName/$submoduleName" }
@{ SubModulePath = "./$submoduleName\$submoduleName" }
@{ SubModulePath = "./$submoduleName/$submoduleFileName" }
@{ SubModulePath = "./$submoduleName\$submoduleFileName" }
$testCases = @(
@{ SubModulePath = "$submoduleName" }
@{ SubModulePath = "$submoduleName\$submoduleName" }
@{ SubModulePath = "$submoduleName/$submoduleName" }
@{ SubModulePath = "$submoduleName\$submoduleFileName" }
@{ SubModulePath = "$submoduleName/$submoduleFileName" }
@{ SubModulePath = ".\$submoduleName" }
@{ SubModulePath = ".\$submoduleName\$submoduleName" }
@{ SubModulePath = ".\$submoduleName/$submoduleName" }
@{ SubModulePath = ".\$submoduleName\$submoduleFileName" }
@{ SubModulePath = ".\$submoduleName/$submoduleFileName" }
@{ SubModulePath = "./$submoduleName" }
@{ SubModulePath = "./$submoduleName/$submoduleName" }
@{ SubModulePath = "./$submoduleName\$submoduleName" }
@{ SubModulePath = "./$submoduleName/$submoduleFileName" }
@{ SubModulePath = "./$submoduleName\$submoduleFileName" }
)
It "Test if NestedModule path is <SubModulePath>" -TestCases $testCases {
It "Test if NestedModule path is <SubModulePath>" -TestCases $testCases {
param($SubModulePath)
New-ModuleManifest $moduleFilePath -NestedModules @($SubModulePath)
@@ -44,7 +44,7 @@
(Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should Be $true
}
It "Test if RootModule path is <SubModulePath>" -TestCases $testCases {
It "Test if RootModule path is <SubModulePath>" -TestCases $testCases {
param($SubModulePath)
New-ModuleManifest $moduleFilePath -RootModule $SubModulePath
@@ -1,52 +1,52 @@
Describe "BooleanParameterDCR Tests" -tags "CI" {
BeforeAll {
Function ParserTestSwitchCmdlet
{
[CmdletBinding()]
param([switch]$switchParam)
return $switchParam
}
Function ParserTestBoolCmdlet2
{
[CmdletBinding()]
param([bool]$First=$false)
return $First
}
}
$tests = @(
@{ inputTest = 0; expected = $false },
@{ inputTest = 000; expected = $false },
@{ inputTest = 0x00; expected = $false },
@{ inputTest = 0.00; expected = $false }
)
It "Test that passing zero works as the value for a Switch parameter, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
param ( $inputTest, $expected )
[bool]$switchTestParam = $inputTest
$result = ParserTestSwitchCmdlet -switchParam:$switchTestParam
$result | should be $expected
}
$tests = @(
@{ inputTest = $(1 -eq 1); expected = $true },
@{ inputTest = $true; expected = $true },
@{ inputTest = $TRUE; expected = $true }
)
It "Test that $true is accepted as a true value for Switch parameters, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
param ( $inputTest, $expected )
[bool]$switchTestParam = $inputTest
$result = ParserTestSwitchCmdlet -switchParam:$switchTestParam
$result | should be $expected
}
It "Test that a nullable boolean is accepted for a boolean parameter." {
[System.Nullable[System.Int32]] $nullBoolVar = $false
$result = ParserTestBoolCmdlet2 $nullBoolVar
$result | should be $false
$result = ParserTestBoolCmdlet2 -First:$nullBoolVar
$result | should be $false
$result = ParserTestBoolCmdlet2 -First $nullBoolVar
$result | should be $false
}
}
Describe "BooleanParameterDCR Tests" -tags "CI" {
BeforeAll {
Function ParserTestSwitchCmdlet
{
[CmdletBinding()]
param([switch]$switchParam)
return $switchParam
}
Function ParserTestBoolCmdlet2
{
[CmdletBinding()]
param([bool]$First=$false)
return $First
}
}
$tests = @(
@{ inputTest = 0; expected = $false },
@{ inputTest = 000; expected = $false },
@{ inputTest = 0x00; expected = $false },
@{ inputTest = 0.00; expected = $false }
)
It "Test that passing zero works as the value for a Switch parameter, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
param ( $inputTest, $expected )
[bool]$switchTestParam = $inputTest
$result = ParserTestSwitchCmdlet -switchParam:$switchTestParam
$result | should be $expected
}
$tests = @(
@{ inputTest = $(1 -eq 1); expected = $true },
@{ inputTest = $true; expected = $true },
@{ inputTest = $TRUE; expected = $true }
)
It "Test that $true is accepted as a true value for Switch parameters, inputTest:<inputTest>,expect:<expected>" -TestCases $tests {
param ( $inputTest, $expected )
[bool]$switchTestParam = $inputTest
$result = ParserTestSwitchCmdlet -switchParam:$switchTestParam
$result | should be $expected
}
It "Test that a nullable boolean is accepted for a boolean parameter." {
[System.Nullable[System.Int32]] $nullBoolVar = $false
$result = ParserTestBoolCmdlet2 $nullBoolVar
$result | should be $false
$result = ParserTestBoolCmdlet2 -First:$nullBoolVar
$result | should be $false
$result = ParserTestBoolCmdlet2 -First $nullBoolVar
$result | should be $false
}
}
@@ -1,15 +1,15 @@
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.Management.Infrastructure.CimCmdlets"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @()
# load the module since it isn't there by default
if ( $IsWindows )
{
import-module CimCmdlets
}
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.Management.Infrastructure.CimCmdlets"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @()
# load the module since it isn't there by default
if ( $IsWindows )
{
import-module CimCmdlets
}
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
@@ -1,10 +1,10 @@
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "Microsoft.PowerShell.ConsoleHost"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @("HostMshSnapinResources.resx")
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "Microsoft.PowerShell.ConsoleHost"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @("HostMshSnapinResources.resx")
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
@@ -1,11 +1,11 @@
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.PowerShell.CoreCLR.Eventing"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @()
# load the module since it isn't there by default
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.PowerShell.CoreCLR.Eventing"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @()
# load the module since it isn't there by default
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
@@ -1,17 +1,17 @@
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "Microsoft.PowerShell.Commands.Management"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = "EventlogResources.resx",
"TransactionResources.resx",
"WebServiceResources.resx",
"HotFixResources.resx",
"ControlPanelResources.resx",
"WmiResources.resx",
"ManagementMshSnapInResources.resx",
"ClearRecycleBinResources.resx",
"ClipboardResources.resx"
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "Microsoft.PowerShell.Commands.Management"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = "EventlogResources.resx",
"TransactionResources.resx",
"WebServiceResources.resx",
"HotFixResources.resx",
"ControlPanelResources.resx",
"WmiResources.resx",
"ManagementMshSnapInResources.resx",
"ClearRecycleBinResources.resx",
"ClipboardResources.resx"
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
@@ -1,9 +1,9 @@
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "System.Management.Automation"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = "CoreMshSnapinResources.resx",
"ErrorPackageRemoting.resx"
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "System.Management.Automation"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = "CoreMshSnapinResources.resx",
"ErrorPackageRemoting.resx"
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
@@ -1,12 +1,12 @@
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.PowerShell.Security"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @("SecurityMshSnapinResources.resx")
# load the module since it isn't there by default
import-module Microsoft.PowerShell.Security
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.PowerShell.Security"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @("SecurityMshSnapinResources.resx")
# load the module since it isn't there by default
import-module Microsoft.PowerShell.Security
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
@@ -1,56 +1,56 @@
function Test-ResourceStrings
{
param ( $AssemblyName, $ExcludeList )
# determine the needed resource directory. If these tests are moved
# this logic will need to change
$repoBase = (Resolve-Path (Join-Path $psScriptRoot ../../../..)).Path
$asmBase = Join-Path $repoBase "src/$AssemblyName"
$resourceDir = Join-Path $asmBase resources
$resourceFiles = Get-ChildItem $resourceDir -Filter *.resx -ea stop |
Where-Object { $excludeList -notcontains $_.Name }
$bindingFlags = [reflection.bindingflags]"NonPublic,Static"
# the resource generation is based on the file name of the .resx file
# and is not in a namespace. We can find all of these classes in the
# ${AssemblyName} assembly
$ASSEMBLY = [appdomain]::CurrentDomain.GetAssemblies()|
Where-Object { $_.FullName -match "$AssemblyName" }
# Validate that the binary you're running has the proper message
# based on the resource files. It is possible that -ResGen could be
# skipped and the messages might become out of sync with what is in
# source
#
# you could argue that we should be generating conditions where the message is delivered
# and then test for that, but that is a check against an ErrorId while this is ensuring
# that the contents of the built binary matches the resx content
#
# Normally you don't want to use reflection to get at the implementation details
# but this tests generated code, so changes there will be consistent across
# all the resource classes we generate
#
# This is the reason why this is not a general module for use. There is
# no other way to run these tests
Describe "Resources strings in $AssemblyName (was -ResGen used with Start-PSBuild)" -tag Feature {
foreach ( $resourceFile in $resourceFiles )
{
# in the event that the id has a space in it, it is replaced with a '_'
$classname = $resourcefile.Name -replace ".resx"
It "'$classname' should be an available type and the strings should be correct" -Skip:(!$IsWindows) {
# get the type from the assembly
$resourceType = $ASSEMBLY.GetType($classname, $false, $true)
# the properties themselves are static internals, so we need
# to using the appropriate bindingflags
$resourceType | Should Not BeNullOrEmpty
# check all the resource strings
$xmlData = [xml](Get-Content $resourceFile.Fullname)
foreach ( $inResource in $xmlData.root.data ) {
$resourceType.GetProperty($inResource.name,$bindingFlags).GetValue(0) | should be $inresource.value
}
}
}
}
}
function Test-ResourceStrings
{
param ( $AssemblyName, $ExcludeList )
# determine the needed resource directory. If these tests are moved
# this logic will need to change
$repoBase = (Resolve-Path (Join-Path $psScriptRoot ../../../..)).Path
$asmBase = Join-Path $repoBase "src/$AssemblyName"
$resourceDir = Join-Path $asmBase resources
$resourceFiles = Get-ChildItem $resourceDir -Filter *.resx -ea stop |
Where-Object { $excludeList -notcontains $_.Name }
$bindingFlags = [reflection.bindingflags]"NonPublic,Static"
# the resource generation is based on the file name of the .resx file
# and is not in a namespace. We can find all of these classes in the
# ${AssemblyName} assembly
$ASSEMBLY = [appdomain]::CurrentDomain.GetAssemblies()|
Where-Object { $_.FullName -match "$AssemblyName" }
# Validate that the binary you're running has the proper message
# based on the resource files. It is possible that -ResGen could be
# skipped and the messages might become out of sync with what is in
# source
#
# you could argue that we should be generating conditions where the message is delivered
# and then test for that, but that is a check against an ErrorId while this is ensuring
# that the contents of the built binary matches the resx content
#
# Normally you don't want to use reflection to get at the implementation details
# but this tests generated code, so changes there will be consistent across
# all the resource classes we generate
#
# This is the reason why this is not a general module for use. There is
# no other way to run these tests
Describe "Resources strings in $AssemblyName (was -ResGen used with Start-PSBuild)" -tag Feature {
foreach ( $resourceFile in $resourceFiles )
{
# in the event that the id has a space in it, it is replaced with a '_'
$classname = $resourcefile.Name -replace ".resx"
It "'$classname' should be an available type and the strings should be correct" -Skip:(!$IsWindows) {
# get the type from the assembly
$resourceType = $ASSEMBLY.GetType($classname, $false, $true)
# the properties themselves are static internals, so we need
# to using the appropriate bindingflags
$resourceType | Should Not BeNullOrEmpty
# check all the resource strings
$xmlData = [xml](Get-Content $resourceFile.Fullname)
foreach ( $inResource in $xmlData.root.data ) {
$resourceType.GetProperty($inResource.name,$bindingFlags).GetValue(0) | should be $inresource.value
}
}
}
}
}
@@ -1,18 +1,18 @@
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "Microsoft.PowerShell.Commands.Utility"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = "CoreMshSnapinResources.resx",
"ErrorPackageRemoting.resx",
"FormatAndOut_out_gridview.resx",
"UtilityMshSnapinResources.resx",
"OutPrinterDisplayStrings.resx",
"UpdateListStrings.resx",
"ConvertFromStringResources.resx",
"ConvertStringResources.resx",
"FlashExtractStrings.resx",
"ImmutableStrings.resx"
import-module Microsoft.Powershell.Utility
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$AssemblyName = "Microsoft.PowerShell.Commands.Utility"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = "CoreMshSnapinResources.resx",
"ErrorPackageRemoting.resx",
"FormatAndOut_out_gridview.resx",
"UtilityMshSnapinResources.resx",
"OutPrinterDisplayStrings.resx",
"UpdateListStrings.resx",
"ConvertFromStringResources.resx",
"ConvertStringResources.resx",
"FlashExtractStrings.resx",
"ImmutableStrings.resx"
import-module Microsoft.Powershell.Utility
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
@@ -1,14 +1,14 @@
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.WSMan.Management"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @()
# load the module since it isn't there by default
if ( $IsWindows ) {
import-module Microsoft.WSMan.Management
}
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList
. "$psscriptroot/TestRunner.ps1"
$assemblyName = "Microsoft.WSMan.Management"
# excluded resources, taken from the 'EmbeddedResource Remove'
# entries in the csproj for the assembly
$excludeList = @()
# load the module since it isn't there by default
if ( $IsWindows ) {
import-module Microsoft.WSMan.Management
}
# run the tests
Test-ResourceStrings -AssemblyName $AssemblyName -ExcludeList $excludeList