Skip to content
Merged
6 changes: 3 additions & 3 deletions test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ Describe 'minishell for native executables' -Tag 'CI' {
It 'gets a hashtable object from minishell' {
$output = & $powershell -noprofile { @{'a' = 'b'} }
($output | Measure-Object).Count | Should -Be 1
$output | Should -BeOfType 'Hashtable'
$output | Should -BeOfType Hashtable
$output['a'] | Should -Be 'b'
}

It 'gets the error stream from minishell' {
$output = & $powershell -noprofile { Write-Error 'foo' } 2>&1
($output | Measure-Object).Count | Should -Be 1
$output | Should -BeOfType 'System.Management.Automation.ErrorRecord'
$output | Should -BeOfType System.Management.Automation.ErrorRecord
$output.FullyQualifiedErrorId | Should -Be 'Microsoft.PowerShell.Commands.WriteErrorException'
}

It 'gets the information stream from minishell' {
$output = & $powershell -noprofile { Write-Information 'foo' } 6>&1
($output | Measure-Object).Count | Should -Be 1
$output | Should -BeOfType 'System.Management.Automation.InformationRecord'
$output | Should -BeOfType System.Management.Automation.InformationRecord
$output | Should -Be 'foo'
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/powershell/Host/PSVersionTable.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ Describe "PSVersionTable" -Tags "CI" {
}

It "PSVersion property" {
$PSVersionTable.PSVersion | Should -BeOfType "System.Management.Automation.SemanticVersion"
$PSVersionTable.PSVersion | Should -BeOfType System.Management.Automation.SemanticVersion
$PSVersionTable.PSVersion | Should -BeExactly $expectedPSVersion
$PSVersionTable.PSVersion | Should -Match $expectedVersionPattern
$PSVersionTable.PSVersion.Major | Should -Be 7
}

It "GitCommitId property" {
$PSVersionTable.GitCommitId | Should -BeOfType "System.String"
$PSVersionTable.GitCommitId | Should -BeOfType System.String
$PSVersionTable.GitCommitId | Should -Match $expectedGitCommitIdPattern
$PSVersionTable.GitCommitId | Should -Not -Match $unexpectectGitCommitIdPattern
$PSVersionTable.GitCommitId | Should -BeExactly $rawGitCommitId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Describe "Exception from initializer" -Tags "CI" {

It "static member w/ ctor" {
$e = { $null = [MSFT_6397334c]::a } | Should -Throw -PassThru
$e.Exception | Should -BeOfType 'System.TypeInitializationException'
$e.Exception | Should -BeOfType System.TypeInitializationException
$e.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should -BeExactly 'InvalidCastFromStringToInteger'
$e.Exception.InnerException.InnerException.ErrorRecord.InvocationInfo.Line | Should -Match 'a = "zz"'
}
Expand Down
30 changes: 15 additions & 15 deletions test/powershell/Language/Operators/RangeOperator.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Describe "Range Operator" -Tags CI {
It "Range operator generates arrays of integers" {
$Range = 5..8
$Range.count | Should -Be 4
$Range[0] | Should -BeOfType [int]
$Range[1] | Should -BeOfType [int]
$Range[2] | Should -BeOfType [int]
$Range[3] | Should -BeOfType [int]
$Range[0] | Should -BeOfType int
$Range[1] | Should -BeOfType int
$Range[2] | Should -BeOfType int
$Range[3] | Should -BeOfType int

$Range[0] | Should -Be 5
$Range[1] | Should -Be 6
Expand All @@ -28,7 +28,7 @@ Describe "Range Operator" -Tags CI {
It "Range operator support single-item sequences" {
$Range = 0..0
$Range.count | Should -Be 1
$Range[0] | Should -BeOfType [int]
$Range[0] | Should -BeOfType int
$Range[0] | Should -Be 0
}

Expand Down Expand Up @@ -92,21 +92,21 @@ Describe "Range Operator" -Tags CI {
It "Range operator generates an array of [char] from single-character operands" {
$CharRange = 'A'..'E'
$CharRange.count | Should -Be 5
$CharRange[0] | Should -BeOfType [char]
$CharRange[1] | Should -BeOfType [char]
$CharRange[2] | Should -BeOfType [char]
$CharRange[3] | Should -BeOfType [char]
$CharRange[4] | Should -BeOfType [char]
$CharRange[0] | Should -BeOfType char
$CharRange[1] | Should -BeOfType char
$CharRange[2] | Should -BeOfType char
$CharRange[3] | Should -BeOfType char
$CharRange[4] | Should -BeOfType char
}

It "Range operator enumerator generates an array of [string] from single-character operands" {
$CharRange = 'A'..'E' | ForEach-Object { $_ }
$CharRange.count | Should -Be 5
$CharRange[0] | Should -BeOfType [char]
$CharRange[1] | Should -BeOfType [char]
$CharRange[2] | Should -BeOfType [char]
$CharRange[3] | Should -BeOfType [char]
$CharRange[4] | Should -BeOfType [char]
$CharRange[0] | Should -BeOfType char
$CharRange[1] | Should -BeOfType char
$CharRange[2] | Should -BeOfType char
$CharRange[3] | Should -BeOfType char
$CharRange[4] | Should -BeOfType char
}

It "Range operator works in ascending and descending order" {
Expand Down
4 changes: 2 additions & 2 deletions test/powershell/Language/Operators/TernaryOperator.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Describe "Using of ternary operator" -Tags CI {
It "Use ternary operator with assignments" {
$IsCoreCLR ? ([string]$var = 'string') : 'blah' > $null
$var = [System.IO.FileInfo]::new('abc')
$var | Should -BeOfType [string]
$var | Should -BeOfType string
$var | Should -BeExactly 'abc'
}

Expand All @@ -82,7 +82,7 @@ Describe "Using of ternary operator" -Tags CI {

It "Return script block from ternary expression" {
$result = ${IsCoreCLR}?{'Core'}:{'Desktop'}
$result | Should -BeOfType [scriptblock]
$result | Should -BeOfType scriptblock
& $result | Should -BeExactly 'Core'
}

Expand Down
4 changes: 2 additions & 2 deletions test/powershell/Language/Parser/Ast.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Describe "The SafeGetValue method on AST returns safe values" -Tags "CI" {
@{ one = 1 }
}.ast.Find({$args[0] -is $HashtableAstType}, $true)
$HtAst | Should -Not -BeNullOrEmpty
$HtAst.SafeGetValue() | Should -BeOfType "Hashtable"
$HtAst.SafeGetValue() | Should -BeOfType Hashtable
}
It "An Array is returned from a LiteralArrayAst" {
$ArrayAstType = [ArrayLiteralAst]
$ArrayAst = {
@( 1,2,3,4)
}.ast.Find({$args[0] -is $ArrayAstType}, $true)
$ArrayAst | Should -Not -BeNullOrEmpty
,$ArrayAst.SafeGetValue() | Should -BeOfType "Object[]"
,$ArrayAst.SafeGetValue() | Should -BeOfType Object[]
}
It "The proper error is returned when a variable is referenced" {
$ast = { $a }.Ast.Find({$args[0] -is "VariableExpressionAst"},$true)
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/Language/Parser/Parser.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ foo``u{2195}abc
It "Test that typing a number at the command line will return that number. (line 1630)" {
$result = ExecuteCommand '3'
$result | Should -Be "3"
$result | Should -BeOfType [int]
$result | Should -BeOfType int
}

It "This test will check that an msh script can be run without invoking. (line 1641)" {
Expand Down
16 changes: 8 additions & 8 deletions test/powershell/Language/Parser/Parsing.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ Describe "Ternary Operator parsing" -Tags CI {
$tks[0].Text | Should -BeExactly $Script

if ($TokenKind -eq "Variable") {
$result.EndBlock.Statements[0].PipelineElements[0].Expression | Should -BeOfType 'System.Management.Automation.Language.VariableExpressionAst'
$result.EndBlock.Statements[0].PipelineElements[0].Expression | Should -BeOfType System.Management.Automation.Language.VariableExpressionAst
$result.EndBlock.Statements[0].PipelineElements[0].Expression.Extent.Text | Should -BeExactly $Script
} else {
$result.EndBlock.Statements[0].PipelineElements[0].CommandElements[0] | Should -BeOfType 'System.Management.Automation.Language.StringConstantExpressionAst'
$result.EndBlock.Statements[0].PipelineElements[0].CommandElements[0] | Should -BeOfType System.Management.Automation.Language.StringConstantExpressionAst
$result.EndBlock.Statements[0].PipelineElements[0].CommandElements[0].Extent.Text | Should -BeExactly $Script
}
}
Expand Down Expand Up @@ -441,9 +441,9 @@ Describe "Ternary Operator parsing" -Tags CI {
$ers[1].ErrorId | Should -BeExactly 'ExpectedValueExpression'

$expr = $result.EndBlock.Statements[0].PipelineElements[0].Expression
$expr | Should -BeOfType 'System.Management.Automation.Language.TernaryExpressionAst'
$expr.IfTrue | Should -BeOfType 'System.Management.Automation.Language.ErrorExpressionAst'
$expr.IfFalse | Should -BeOfType 'System.Management.Automation.Language.ErrorExpressionAst'
$expr | Should -BeOfType System.Management.Automation.Language.TernaryExpressionAst
$expr.IfTrue | Should -BeOfType System.Management.Automation.Language.ErrorExpressionAst
$expr.IfFalse | Should -BeOfType System.Management.Automation.Language.ErrorExpressionAst
}

It "Generate ternary AST when operands are missing - '`$true ? : 3'" {
Expand All @@ -454,8 +454,8 @@ Describe "Ternary Operator parsing" -Tags CI {
$ers.IncompleteInput | Should -BeFalse
$ers.ErrorId | Should -BeExactly "ExpectedValueExpression"
$expr = $result.EndBlock.Statements[0].PipelineElements[0].Expression
$expr | Should -BeOfType 'System.Management.Automation.Language.TernaryExpressionAst'
$expr.IfTrue | Should -BeOfType 'System.Management.Automation.Language.ErrorExpressionAst'
$expr.IfFalse | Should -BeOfType 'System.Management.Automation.Language.ConstantExpressionAst'
$expr | Should -BeOfType System.Management.Automation.Language.TernaryExpressionAst
$expr.IfTrue | Should -BeOfType System.Management.Automation.Language.ErrorExpressionAst
$expr.IfFalse | Should -BeOfType System.Management.Automation.Language.ConstantExpressionAst
}
}
4 changes: 2 additions & 2 deletions test/powershell/Language/Scripting/ActionPreference.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ Describe "Tests for (error, warning, etc) action preference" -Tags "CI" {

It '$err.Count' { $err.Count | Should -Be 1 }
It '$err[0] should not be $null' { $err[0] | Should -Not -BeNullOrEmpty }
It '$err[0].GetType().Name' { $err[0] | Should -BeOfType "System.Management.Automation.ActionPreferenceStopException" }
It '$err[0].GetType().Name' { $err[0] | Should -BeOfType System.Management.Automation.ActionPreferenceStopException }
It '$err[0].ErrorRecord' { $err[0].ErrorRecord | Should -Not -BeNullOrEmpty }
It '$err[0].ErrorRecord.Exception.GetType().Name' { $err[0].ErrorRecord.Exception | Should -BeOfType "System.Management.Automation.ItemNotFoundException" }
It '$err[0].ErrorRecord.Exception.GetType().Name' { $err[0].ErrorRecord.Exception | Should -BeOfType System.Management.Automation.ItemNotFoundException }
}

It 'Action preference of Ignore can be set as a preference variable using a string value' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
It 'Hashtable conversion to PSCustomObject retains insertion order of hashtable keys when passed a hashliteral' {

$x = [pscustomobject]@{one=1;two=2}
$x | Should -BeOfType "System.Management.automation.psobject"
$x | Should -BeOfType System.Management.automation.psobject

$p = 0
# Checks if the first property is One
Expand All @@ -60,7 +60,7 @@ Describe "Tests for hashtable to PSCustomObject conversion" -Tags "CI" {
It 'Conversion of Ordered hashtable to PSCustomObject should succeed' {

$x = [pscustomobject][ordered]@{one=1;two=2}
$x | Should -BeOfType "System.Management.automation.psobject"
$x | Should -BeOfType System.Management.automation.psobject

$p = 0
# Checks if the first property is One
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/Language/Scripting/I18n.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Describe 'Testing of script internationalization' -Tags "CI" {
import-localizedData mydata -uiculture nl-NL -ErrorAction SilentlyContinue -ErrorVariable ev

$ev | Should -Not -BeNullOrEmpty
$ev[0].Exception | Should -BeOfType "System.Management.Automation.PSInvalidOperationException"
$ev[0].Exception | Should -BeOfType System.Management.Automation.PSInvalidOperationException
}

It 'Import different file name is done correctly' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ Describe "Native streams behavior with PowerShell" -Tags 'CI' {
It 'uses ErrorRecord object to return stderr output' {
($out | Measure-Object).Count | Should -BeGreaterThan 1

$out[0] | Should -BeOfType 'System.Management.Automation.ErrorRecord'
$out[0] | Should -BeOfType System.Management.Automation.ErrorRecord
$out[0].FullyQualifiedErrorId | Should -Be 'NativeCommandError'

$out | Select-Object -Skip 1 | ForEach-Object {
$_ | Should -BeOfType 'System.Management.Automation.ErrorRecord'
$_ | Should -BeOfType System.Management.Automation.ErrorRecord
$_.FullyQualifiedErrorId | Should -Be 'NativeCommandErrorMessage'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ Describe "Update both OutVariable and ErrorVariable" -Tags "CI" {
It '$get_item_err.count and $get_item_err[0].exception' {
$get_item_err.count | Should -Be 1
$get_item_err[0].exception | Should -Not -BeNullOrEmpty
$get_item_err[0].exception | Should -BeOftype 'System.Management.Automation.ItemNotFoundException'
$get_item_err[0].exception | Should -BeOfType System.Management.Automation.ItemNotFoundException
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/powershell/Modules/CimCmdlets/CimInstance.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Describe "CimInstance cmdlet tests" -Tag @("CI") {
}

It "GetCimSessionInstanceId method invocation should return data" -Pending:(-not $IsWindows) {
$instance.GetCimSessionInstanceId() | Should -BeOfType "Guid"
$instance.GetCimSessionInstanceId() | Should -BeOfType Guid
}

It "should produce an error for a non-existing classname" -Pending:(-not $IsWindows) {
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/Modules/CimCmdlets/CimSession.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Describe "New-CimSession" -Tag @("CI","RequireAdminOnWindows") {
$session = New-CimSession -ComputerName . -Name $sessionName
$sessions += $session
$session.Name | Should -BeExactly $sessionName
$session.InstanceId | Should -BeOfType "System.Guid"
$session.InstanceId | Should -BeOfType System.Guid
}

It "A Cim session can be retrieved" -Pending:(-not $IsWindows) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ Describe "Import-Module should be case insensitive" -Tags 'CI' {
Set-Content -Path "$modulesPath/$modulePath/TESTMODULE.psm1" -Value "function mytest { 'hello' }"
Import-Module testMODULE
$m = Get-Module TESTmodule
$m | Should -BeOfType "System.Management.Automation.PSModuleInfo"
$m | Should -BeOfType System.Management.Automation.PSModuleInfo
$m.Name | Should -BeIn "TESTMODULE"
mytest | Should -BeExactly "hello"
Remove-Module TestModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ Describe "Job Cmdlet Tests" -Tag "CI" {
Get-Job | Remove-Job -Force
}
It "Start-Job produces a job object" {
$j | Should -BeOfType "System.Management.Automation.Job"
$j | Should -BeOfType System.Management.Automation.Job
$j.Name | Should -BeExactly "My Job"
}
It "Get-Job retrieves a job object" {
(Get-Job -Id $j.Id) | Should -BeOfType "System.Management.Automation.Job"
(Get-Job -Id $j.Id) | Should -BeOfType System.Management.Automation.Job
}
It "Get-Job retrieves an array of job objects" {
Start-Job -ScriptBlock { 2 * 2 }
$jobs = Get-Job
$jobs.Count | Should -Be 2
foreach ($job in $jobs)
{
$job | Should -BeOfType "System.Management.Automation.Job"
$job | Should -BeOfType System.Management.Automation.Job
}
}
It "Remove-Job can remove a job" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ namespace PowershellTestConfigNamespace
}

$resultContent = invoke-expression ($result)
$resultContent | Should -BeOfType "System.Collections.Hashtable"
$resultContent | Should -BeOfType System.Collections.Hashtable

# The default created hashtable in the session configuration file would have the
# following keys which we are validating below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Describe "Remote module tests" -Tags 'Feature','RequireAdminOnWindows' {
}
$modules = Get-Module @parameters
$modules | Should -Not -BeNullOrEmpty
$modules[0] | Should -BeOfType "System.Management.Automation.PSModuleInfo"
$modules[0] | Should -BeOfType System.Management.Automation.PSModuleInfo
}

It "Get-Module can be called as an API with '<parameter>' = '<value>'" -TestCases @(
Expand All @@ -74,7 +74,7 @@ Describe "Remote module tests" -Tags 'Feature','RequireAdminOnWindows' {
$getModuleCommand = [Microsoft.PowerShell.Commands.GetModuleCommand]::new()
$getModuleCommand.$parameter = $value
if ($parameter -eq "FullyQualifiedName") {
$getModuleCommand.FullyQualifiedName | Should -BeOfType "Microsoft.PowerShell.Commands.ModuleSpecification"
$getModuleCommand.FullyQualifiedName | Should -BeOfType Microsoft.PowerShell.Commands.ModuleSpecification
$getModuleCommand.FullyQualifiedName.Name | Should -BeExactly "foo"
$getModuleCommand.FullyQualifiedName.Version | Should -Be "1.2.3"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Describe "Remote import-module tests" -Tags 'Feature','RequireAdminOnWindows' {
$importModuleCommand.$parameter = $value
if ($parameter -eq "FullyQualifiedName") {
$importModuleCommand.FullyQualifiedName.Count | Should -BeExactly 2
$importModuleCommand.FullyQualifiedName | Should -BeOfType "Microsoft.PowerShell.Commands.ModuleSpecification"
$importModuleCommand.FullyQualifiedName | Should -BeOfType Microsoft.PowerShell.Commands.ModuleSpecification
$importModuleCommand.FullyQualifiedName[0].Name | Should -BeExactly "foo"
$importModuleCommand.FullyQualifiedName[0].RequiredVersion | Should -Be "0.0"
$importModuleCommand.FullyQualifiedName[1].Name | Should -BeExactly "bar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Describe "Basic Alias Provider Tests" -Tags "CI" {

It "Test executing the new alias" {
$result = Invoke-Expression $testAliasName
$result | Should -BeOfType [DateTime]
$result | Should -BeOfType DateTime
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ Describe "Basic FileSystem Provider Tests" -Tags "CI" {
}

It "Can get an appx package item" -Skip:$skipTest {
Get-Item $pkgDir\Calculator.exe -ErrorAction Stop | Should -BeOfType [System.IO.FileInfo]
Get-Item -Path $pkgDir -ErrorAction Stop | Should -BeOfType [System.IO.DirectoryInfo]
Get-Item $pkgDir\Calculator.exe -ErrorAction Stop | Should -BeOfType System.IO.FileInfo
Get-Item -Path $pkgDir -ErrorAction Stop | Should -BeOfType System.IO.DirectoryInfo
Get-ChildItem -Path $pkgDir -ErrorAction Stop | Should -Not -BeNullOrEmpty
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Describe 'FileSystem Provider Formatting' -Tag "CI","RequireAdminOnWindows" {
New-Item -Path $modeTestDir -Name $itemName -ItemType $itemType
}

$item | Should -BeOfType "System.IO.FileSystemInfo"
$item | Should -BeOfType System.IO.FileSystemInfo

$actualMode = [Microsoft.PowerShell.Commands.FileSystemProvider]::Mode($item)
$actualMode | Should -BeExactly $expectedMode
Expand Down
Loading