Unify pester test syntax for the arguments of -BeOfType (#11558)

This commit is contained in:
xtqqczze 2020-01-24 19:00:37 +00:00 committed by Dongbo Wang
parent a7a2b12336
commit 920b671fb4
68 changed files with 216 additions and 216 deletions

View file

@ -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'
}
}

View file

@ -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

View file

@ -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"'
}

View file

@ -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
@ -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
}
@ -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" {

View file

@ -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'
}
@ -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'
}

View file

@ -8,7 +8,7 @@ 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]
@ -16,7 +16,7 @@ Describe "The SafeGetValue method on AST returns safe values" -Tags "CI" {
@( 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)

View file

@ -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)" {

View file

@ -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
}
}
@ -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'" {
@ -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
}
}

View file

@ -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' {

View file

@ -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
@ -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

View file

@ -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' {

View file

@ -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'
}
}

View file

@ -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
}
}

View file

@ -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) {

View file

@ -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) {

View file

@ -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

View file

@ -9,11 +9,11 @@ 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 }
@ -21,7 +21,7 @@ Describe "Job Cmdlet Tests" -Tag "CI" {
$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" {

View file

@ -630,7 +630,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.

View file

@ -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 @(
@ -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 {

View file

@ -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"

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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

View file

@ -1008,7 +1008,7 @@ try {
It "Verify type returned by Get-ComputerInfo" {
$computerInfo = Get-ComputerInfo
$computerInfo | Should -BeOfType 'Microsoft.PowerShell.Commands.ComputerInfo'
$computerInfo | Should -BeOfType Microsoft.PowerShell.Commands.ComputerInfo
}
It "Verify progress records in Get-ComputerInfo" {
@ -1075,7 +1075,7 @@ try {
$expectedProperties = @("BiosBIOSVersion")
$propertyFilter = "BiosBIOSVersion"
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be 1
$computerInfoWithProp.$propertyFilter | Should -Be $expected.$propertyFilter
}
@ -1088,7 +1088,7 @@ try {
$expectedProperties = @("BiosBIOSVersion","BiosBuildNumber","BiosCaption")
$propertyFilter = @("BiosBIOSVersion","BiosBuildNumber","BiosCaption")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be 3
foreach($property in $propertyFilter) {
$ComputerInfoWithProp.$property | Should -Be $Expected.$property
@ -1103,7 +1103,7 @@ try {
$expectedProperties = $null
$propertyFilter = @("BiosBIOSVersionXXX")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be 0
}
@ -1115,7 +1115,7 @@ try {
$expectedProperties = $null
$propertyFilter = @("BiosBIOSVersionXXX","InvalidProperty1","InvalidProperty2","InvalidProperty3")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be 0
}
@ -1127,7 +1127,7 @@ try {
$expectedProperties = @("BiosCodeSet","BiosCurrentLanguage","BiosDescription")
$propertyFilter = @("InvalidProperty1","BiosCodeSet","BiosCurrentLanguage","BiosDescription")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
$realProperties = $propertyFilter | Where-Object { $_ -notmatch "^InvalidProperty[0-9]+" }
@($computerInfoWithProp.psobject.properties).count | Should -Be $realProperties.Count
foreach ( $property in $realProperties )
@ -1144,7 +1144,7 @@ try {
$expectedProperties = @("BiosCodeSet","BiosCurrentLanguage","BiosDescription")
$propertyFilter = @("BiosCodeSet","InvalidProperty1","BiosCurrentLanguage","BiosDescription","InvalidProperty2")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
$realProperties = $propertyFilter | Where-Object { $_ -notmatch "^InvalidProperty[0-9]+" }
@($computerInfoWithProp.psobject.properties).count | Should -Be $realProperties.Count
foreach ( $property in $realProperties )
@ -1161,7 +1161,7 @@ try {
$expectedProperties = @("BiosCaption","BiosCharacteristics","BiosCodeSet","BiosCurrentLanguage")
$propertyFilter = @("BiosC*")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be $expectedProperties.Count
foreach ( $property in $expectedProperties )
{
@ -1177,7 +1177,7 @@ try {
$expectedProperties = @("BiosCaption","BiosCharacteristics","BiosCodeSet","BiosCurrentLanguage","CsCaption")
$propertyFilter = @("BiosC*","CsCaption")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be $expectedProperties.Count
foreach ( $property in $expectedProperties )
{
@ -1193,7 +1193,7 @@ try {
$expectedProperties = @("BiosCaption","BiosCharacteristics","BiosCodeSet","BiosCurrentLanguage","CsCaption")
$propertyFilter = @("CsCaption","InvalidProperty1","BiosC*")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be $expectedProperties.Count
foreach ( $property in $expectedProperties )
{
@ -1209,7 +1209,7 @@ try {
$expectedProperties = $null
$propertyFilter = @("BiosBIOSVersionX*")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$computerInfoWithProp | Should -BeOfType pscustomobject
@($computerInfoWithProp.psobject.properties).count | Should -Be 0
}
}

View file

@ -33,13 +33,13 @@ Describe "Get-Content" -Tags "CI" {
$content = (Get-Content -Path $testPath)
$content | Should -BeExactly $testString
$content.Count | Should -Be 1
$content | Should -BeOfType "System.String"
$content | Should -BeOfType System.String
}
It "Should deliver an array object when listing a file with multiple lines and the correct information from a file" {
$content = (Get-Content -Path $testPath2)
@(Compare-Object $content $testString2.Split($nl) -SyncWindow 0).Length | Should -Be 0
,$content | Should -BeOfType "System.Array"
,$content | Should -BeOfType System.Array
}
It "Should be able to return a specific line from a file" {
@ -119,7 +119,7 @@ baz
$expected = 'foo'
$actual = Get-Content -Path $testPath -Tail $tailCount -Encoding $encodingName
$actual | Should -BeOfType [string]
$actual | Should -BeOfType string
$actual.Length | Should -Be $tailCount
$actual[0] | Should -BeExactly $expected
}
@ -224,7 +224,7 @@ baz
Get-Content -Path $testPath | Should -BeExactly $testString
Get-Content -Path $testPath -Stream hello | Should -BeExactly "World"
$item = Get-Item -Path $testPath -Stream hello
$item | Should -BeOfType 'System.Management.Automation.Internal.AlternateStreamData'
$item | Should -BeOfType System.Management.Automation.Internal.AlternateStreamData
$item.Stream | Should -BeExactly "hello"
Clear-Content -Path $testPath -Stream hello
Get-Content -Path $testPath -Stream hello | Should -BeNullOrEmpty

View file

@ -15,14 +15,14 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
It "should return an array of eventlogs objects when called with -AsString parameter" -Pending:($true) {
{ $result=Get-EventLog -AsString -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
,$result | Should -BeOfType "System.Array"
,$result | Should -BeOfType System.Array
$result | Should -BeExactly "Application"
$result.Count | Should -BeGreaterThan 3
}
It "should return a list of eventlog objects when called with -List parameter" -Pending:($true) {
{ $result=Get-EventLog -List -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
,$result | Should -BeOfType "System.Array"
,$result | Should -BeOfType System.Array
{$logs=$result | Select-Object -ExpandProperty Log} | Should -Not -Throw
$logs | Should -BeExactly "System"
$logs.Count | Should -BeGreaterThan 3
@ -31,7 +31,7 @@ Describe "Get-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
{ $result=get-eventlog -LogName Application -Newest 100 -ErrorAction Stop } | Should -Not -Throw
$result | Should -Not -BeNullOrEmpty
$result.Length | Should -BeLessThan 100
$result[0] | Should -BeOfType "EventLogEntry"
$result[0] | Should -BeOfType EventLogEntry
}
It "should throw 'AmbiguousParameterSetException' when called with both -LogName and -List parameters" -Pending:($true) {
{ Get-EventLog -LogName System -List -ErrorAction Stop } | Should -Throw -ErrorId "AmbiguousParameterSet,Microsoft.PowerShell.Commands.GetEventLogCommand"

View file

@ -11,20 +11,20 @@ Describe "Get-Item" -Tags "CI" {
}
It "Should list all the items in the current working directory when asterisk is used" {
$items = Get-Item (Join-Path -Path $PSScriptRoot -ChildPath "*")
,$items | Should -BeOfType 'System.Object[]'
,$items | Should -BeOfType System.Object[]
}
It "Should return the name of the current working directory when a dot is used" {
$item = Get-Item $PSScriptRoot
$item | Should -BeOfType 'System.IO.DirectoryInfo'
$item | Should -BeOfType System.IO.DirectoryInfo
$item.Name | Should -BeExactly (Split-Path $PSScriptRoot -Leaf)
}
It "Should return the proper Name and BaseType for directory objects vs file system objects" {
$rootitem = Get-Item $PSScriptRoot
$rootitem | Should -BeOfType 'System.IO.DirectoryInfo'
$rootitem | Should -BeOfType System.IO.DirectoryInfo
$childitem = (Get-Item (Join-Path -Path $PSScriptRoot -ChildPath Get-Item.Tests.ps1))
$childitem | Should -BeOfType 'System.IO.FileInfo'
$childitem | Should -BeOfType System.IO.FileInfo
}
It "Using -literalpath should find no additional files" {
@ -127,7 +127,7 @@ Describe "Get-Item" -Tags "CI" {
Context "Registry Provider" {
It "Can retrieve an item from registry" -skip:$skipNotWindows {
${result} = Get-Item HKLM:/Software
${result} | Should -BeOfType "Microsoft.Win32.RegistryKey"
${result} | Should -BeOfType Microsoft.Win32.RegistryKey
}
}

View file

@ -46,7 +46,7 @@ Describe "Get-Process" -Tags "CI" {
$idleProcessPid = 0
}
It "Should return a type of Object[] for Get-Process cmdlet" -Pending:$IsMacOS {
,$ps | Should -BeOfType "System.Object[]"
,$ps | Should -BeOfType System.Object[]
}
It "Should have not empty Name flags set for Get-Process object" -Pending:$IsMacOS {

View file

@ -49,7 +49,7 @@ Describe "Test-Push-Location" -Tags "CI" {
}
It "Should produce a pathinfo object when the passthru parameter is used" {
Push-Location .. -PassThru | ForEach-Object { $_ | Should -BeOfType "System.Management.Automation.PathInfo" }
Push-Location .. -PassThru | ForEach-Object { $_ | Should -BeOfType System.Management.Automation.PathInfo }
}
# final cleanup

View file

@ -61,7 +61,7 @@ Describe "Split-Path" -Tags "CI" {
$actual.Count | Should -Be 2
$actual[0] | Should -BeExactly $testFile1
$actual[1] | Should -BeExactly $testFile2
,$actual | Should -BeOfType "System.Array"
,$actual | Should -BeOfType System.Array
}
It "Should be able to tell if a given path is an absolute path" {

View file

@ -30,14 +30,14 @@ Describe "Test-Connection" -tags "CI" {
Where-Object Status -eq 'Success' |
Select-Object -First 1
$result | Should -BeOfType "Microsoft.PowerShell.Commands.TestConnectionCommand+PingStatus"
$result | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+PingStatus
$result.Ping | Should -Be 1
$result.Source | Should -BeExactly $hostName
$result.Destination | Should -BeExactly $targetName
$result.Address | Should -BeIn @($targetAddress, $targetAddressIPv6)
$result.Status | Should -BeExactly "Success"
$result.Latency | Should -BeOfType "long"
$result.Reply | Should -BeOfType "System.Net.NetworkInformation.PingReply"
$result.Latency | Should -BeOfType long
$result.Reply | Should -BeOfType System.Net.NetworkInformation.PingReply
$result.BufferSize | Should -Be 32
}
@ -228,7 +228,7 @@ Describe "Test-Connection" -tags "CI" {
It "MTUSizeDetect works" -Pending:($env:__INCONTAINER -eq 1) {
$result = Test-Connection $hostName -MtuSize
$result | Should -BeOfType "Microsoft.PowerShell.Commands.TestConnectionCommand+PingMtuStatus"
$result | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+PingMtuStatus
$result.Destination | Should -BeExactly $hostName
$result.Status | Should -BeExactly "Success"
$result.MtuSize | Should -BeGreaterThan 0
@ -237,7 +237,7 @@ Describe "Test-Connection" -tags "CI" {
It "Quiet works" -Pending:($env:__INCONTAINER -eq 1) {
$result = Test-Connection $hostName -MtuSize -Quiet
$result | Should -BeOfType "Int32"
$result | Should -BeOfType Int32
$result | Should -BeGreaterThan 0
}
}
@ -247,7 +247,7 @@ Describe "Test-Connection" -tags "CI" {
# real address is an ipv4 address, so force IPv4
$result = Test-Connection $hostName -TraceRoute -IPv4
$result[0] | Should -BeOfType "Microsoft.PowerShell.Commands.TestConnectionCommand+TraceStatus"
$result[0] | Should -BeOfType Microsoft.PowerShell.Commands.TestConnectionCommand+TraceStatus
$result[0].Source | Should -BeExactly $hostName
$result[0].TargetAddress | Should -BeExactly $realAddress
$result[0].Target | Should -BeExactly $hostName

View file

@ -53,8 +53,8 @@ Describe "Get-Timezone test cases" -Tags "CI" {
$list = Get-TimeZone -ListAvailable
$list.Count | Should -BeGreaterThan 0
,$list | Should -BeOfType "Object[]"
$list[0] | Should -BeOfType "TimeZoneInfo"
,$list | Should -BeOfType Object[]
$list[0] | Should -BeOfType TimeZoneInfo
}
## The local time zone could be set to UTC or GMT*. In this case, the .NET API returns the region ID

View file

@ -3,7 +3,7 @@
Describe "Acl cmdlets are available and operate properly" -Tag CI {
It "Get-Acl returns an ACL object" -pending:(!$IsWindows) {
$ACL = get-acl $TESTDRIVE
$ACL | Should -BeOfType "System.Security.AccessControl.DirectorySecurity"
$ACL | Should -BeOfType System.Security.AccessControl.DirectorySecurity
}
It "Set-Acl can set the ACL of a directory" -pending {
Setup -d testdir

View file

@ -565,7 +565,7 @@ ZoneId=$FileType
$exception = { & $scriptName } | Should -Throw -PassThru
$exception.Exception | Should -BeOfType "System.Management.Automation.PSSecurityException"
$exception.Exception | Should -BeOfType System.Management.Automation.PSSecurityException
}
}

View file

@ -178,7 +178,7 @@ Describe "Add-Member DRT Unit Tests" -Tags "CI" {
$object = @(1,2)
Add-Member -InputObject $object "ABC" "Value1"
Add-Member -InputObject $object "ABC" "Value2" -ErrorVariable errorVar -ErrorAction SilentlyContinue
$errorVar.Exception | Should -BeOfType "System.InvalidOperationException"
$errorVar.Exception | Should -BeOfType System.InvalidOperationException
$errorVar.Exception.Message | Should -Not -BeNullOrEmpty
}
}

View file

@ -31,8 +31,8 @@ a,b,c
$csvContent = Get-Content $testcsv
$actualresult = $csvContent | ConvertFrom-Csv
,$actualresult | Should -BeOfType "System.Array"
$actualresult[0] | Should -BeOfType "PSCustomObject"
,$actualresult | Should -BeOfType System.Array
$actualresult[0] | Should -BeOfType PSCustomObject
#Should have a name property in the result
$actualresult[0].Name | Should -Be $testName
@ -46,8 +46,8 @@ a,b,c
$csvContent = Get-Content $testcsv
$actualresult = $csvContent | ConvertFrom-Csv -Delimiter ";"
,$actualresult | Should -BeOfType "System.Array"
$actualresult[0] | Should -BeOfType "PSCustomObject"
,$actualresult | Should -BeOfType System.Array
$actualresult[0] | Should -BeOfType PSCustomObject
# ConvertFrom-Csv takes the first line of the input as a header by default
$actualresult.Length | Should -Be $($csvContent.Length - 1)

View file

@ -48,7 +48,7 @@ Describe "ConvertTo-Csv" -Tags "CI" {
It "Should output an array of objects" {
$result = $testObject | ConvertTo-Csv
,$result | Should -BeOfType "System.Array"
,$result | Should -BeOfType System.Array
}
It "Should return the type of data in the first element of the output array" {

View file

@ -362,6 +362,6 @@ Describe 'ForEach-Object -Parallel Functional Tests' -Tags 'Feature' {
$results.Count | Should -BeExactly 2
$results[0] | Should -BeExactly 'Output 1'
$results[1].FullyQualifiedErrorId | Should -BeExactly 'PSTaskException'
$results[1].Exception | Should -BeOfType [System.Management.Automation.PipelineStoppedException]
$results[1].Exception | Should -BeOfType System.Management.Automation.PipelineStoppedException
}
}

View file

@ -144,7 +144,7 @@ public enum TestSByteEnum : sbyte {
$result = Format-Hex -InputObject $InputObject
$result.count | Should -Be $Count
$result | Should -BeOfType 'Microsoft.PowerShell.Commands.ByteCollection'
$result | Should -BeOfType Microsoft.PowerShell.Commands.ByteCollection
$result.ToString() | Should -MatchExactly $ExpectedResult
}
}
@ -267,7 +267,7 @@ public enum TestSByteEnum : sbyte {
$result = $InputObject | Format-Hex
$result.Count | Should -Be $Count
$result | Should -BeOfType 'Microsoft.PowerShell.Commands.ByteCollection'
$result | Should -BeOfType Microsoft.PowerShell.Commands.ByteCollection
$result[0].ToString() | Should -MatchExactly $ExpectedResult
if ($result.count -gt 1) {
@ -393,7 +393,7 @@ public enum TestSByteEnum : sbyte {
$result = Format-Hex -LiteralPath $Path
}
$result | Should -BeOfType 'Microsoft.PowerShell.Commands.ByteCollection'
$result | Should -BeOfType Microsoft.PowerShell.Commands.ByteCollection
$result[0].ToString() | Should -MatchExactly $ExpectedResult
if ($result.count -gt 1) {
@ -466,7 +466,7 @@ public enum TestSByteEnum : sbyte {
$result = Format-Hex -InputObject 'hello' -Encoding $Encoding
$result.count | Should -Be $Count
$result | Should -BeOfType 'Microsoft.PowerShell.Commands.ByteCollection'
$result | Should -BeOfType Microsoft.PowerShell.Commands.ByteCollection
$result[0].ToString() | Should -MatchExactly $ExpectedResult
}
}
@ -556,7 +556,7 @@ public enum TestSByteEnum : sbyte {
$result = Format-Hex $inputFile1
$result | Should -Not -BeNullOrEmpty
, $result | Should -BeOfType 'Microsoft.PowerShell.Commands.ByteCollection'
, $result | Should -BeOfType Microsoft.PowerShell.Commands.ByteCollection
$actualResult = $result.ToString()
$actualResult | Should -MatchExactly $inputText1
}
@ -566,7 +566,7 @@ public enum TestSByteEnum : sbyte {
$result = Get-ChildItem $inputFile1 | Format-Hex
$result | Should -Not -BeNullOrEmpty
, $result | Should -BeOfType 'Microsoft.PowerShell.Commands.ByteCollection'
, $result | Should -BeOfType Microsoft.PowerShell.Commands.ByteCollection
$actualResult = $result.ToString()
$actualResult | Should -MatchExactly $inputText1
}
@ -576,7 +576,7 @@ public enum TestSByteEnum : sbyte {
$result = "a" * 30 | Format-Hex
$result | Should -Not -BeNullOrEmpty
$result | Should -BeOfType 'Microsoft.PowerShell.Commands.ByteCollection'
$result | Should -BeOfType Microsoft.PowerShell.Commands.ByteCollection
$result[0].ToString() | Should -MatchExactly "0000000000000000 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa"
$result[1].ToString() | Should -MatchExactly "0000000000000010 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaa "
}

View file

@ -168,20 +168,20 @@ Describe "Get-Alias" -Tags "CI" {
$val1 | ForEach-Object{ $i++};
if($i -lt 2) {
$val1 | Should -BeOfType "System.Management.Automation.CommandInfo"
$val1 | Should -BeOfType System.Management.Automation.CommandInfo
}
else
{
,$val1 | Should -BeOfType "System.Array"
,$val1 | Should -BeOfType System.Array
}
$val2 | ForEach-Object{ $i++};
if($i -lt 2) {
$val2 | Should -BeOfType "System.Management.Automation.CommandInfo"
$val2 | Should -BeOfType System.Management.Automation.CommandInfo
}
else
{
,$val2 | Should -BeOfType "System.Array"
,$val2 | Should -BeOfType System.Array
}
}

View file

@ -6,10 +6,10 @@ Describe "Get-Culture" -Tags "CI" {
It "Should return a type of CultureInfo for Get-Culture cmdlet" {
$culture = Get-Culture
$culture | Should -BeOfType [CultureInfo]
$culture | Should -BeOfType CultureInfo
($culture).EnglishName | Should -BeExactly $Host.CurrentCulture.EnglishName
Get-Culture -NoUserOverrides | Should -BeOfType [CultureInfo]
Get-Culture -NoUserOverrides | Should -BeOfType CultureInfo
}
It "Should have (Get-Culture).Name variable be equivalent to `$PSCulture" {
@ -20,11 +20,11 @@ Describe "Get-Culture" -Tags "CI" {
It "Should return the specified culture with '-Name' parameter" {
$ci = Get-Culture -Name ru-RU
$ci | Should -BeOfType [CultureInfo]
$ci | Should -BeOfType CultureInfo
$ci.Name | Should -BeExactly "ru-RU"
$ci = Get-Culture -Name ru-RU -NoUserOverrides
$ci | Should -BeOfType [CultureInfo]
$ci | Should -BeOfType CultureInfo
$ci.Name | Should -BeExactly "ru-RU"
}
@ -32,10 +32,10 @@ Describe "Get-Culture" -Tags "CI" {
$ciArray = Get-Culture "", "ru-RU"
$ciArray | Should -HaveCount 2
$ciArray[0] | Should -BeOfType [CultureInfo]
$ciArray[0] | Should -BeOfType CultureInfo
$ciArray[0].EnglishName | Should -BeExactly "Invariant Language (Invariant Country)"
$ciArray[1] | Should -BeOfType [CultureInfo]
$ciArray[1] | Should -BeOfType CultureInfo
$ciArray[1].Name | Should -BeExactly "ru-RU"
$ciArray[1].EnglishName | Should -BeExactly "Russian (Russia)"
}
@ -44,9 +44,9 @@ Describe "Get-Culture" -Tags "CI" {
$ciArray = "", "ru-RU" | Get-Culture
$ciArray | Should -HaveCount 2
$ciArray[0] | Should -BeOfType [CultureInfo]
$ciArray[0] | Should -BeOfType CultureInfo
$ciArray[0].EnglishName | Should -BeExactly "Invariant Language (Invariant Country)"
$ciArray[1] | Should -BeOfType [CultureInfo]
$ciArray[1] | Should -BeOfType CultureInfo
$ciArray[1].Name | Should -BeExactly "ru-RU"
$ciArray[1].EnglishName | Should -BeExactly "Russian (Russia)"
}
@ -55,7 +55,7 @@ Describe "Get-Culture" -Tags "CI" {
$ciArray = Get-Culture -ListAvailable
$ciArray.Count | Should -BeGreaterThan 0
$ciArray[0] | Should -BeOfType [CultureInfo]
$ciArray[0] | Should -BeOfType CultureInfo
}
It "Should write an error on unsupported culture name" {

View file

@ -13,13 +13,13 @@ Describe 'Get-Error tests' -Tag CI {
$out | Should -BeLikeExactly '*InnerException*'
$err = Get-Error
$err | Should -BeOfType [System.Management.Automation.ErrorRecord]
$err | Should -BeOfType System.Management.Automation.ErrorRecord
$err.PSObject.TypeNames | Should -Not -Contain 'System.Management.Automation.ErrorRecord'
$err.PSObject.TypeNames | Should -Contain 'System.Management.Automation.ErrorRecord#PSExtendedError'
# need to exercise the formatter to validate that the internal types are removed from the error object
$null = $err | Out-String
$err | Should -BeOfType [System.Management.Automation.ErrorRecord]
$err | Should -BeOfType System.Management.Automation.ErrorRecord
$err.PSObject.TypeNames | Should -Contain 'System.Management.Automation.ErrorRecord'
$err.PSObject.TypeNames | Should -Not -Contain 'System.Management.Automation.ErrorRecord#PSExtendedError'
}
@ -83,13 +83,13 @@ Describe 'Get-Error tests' -Tag CI {
$out | Should -BeLikeExactly '*myexception*'
$err = Get-Error
$err | Should -BeOfType [System.Exception]
$err | Should -BeOfType System.Exception
$err.PSObject.TypeNames | Should -Not -Contain 'System.Exception'
$err.PSObject.TypeNames | Should -Contain 'System.Exception#PSExtendedError'
# need to exercise the formatter to validate that the internal types are removed from the error object
$null = $err | Out-String
$err | Should -BeOfType [System.Exception]
$err | Should -BeOfType System.Exception
$err.PSObject.TypeNames | Should -Contain 'System.Exception'
$err.PSObject.TypeNames | Should -Not -Contain 'System.Exception#PSExtendedError'
}

View file

@ -6,7 +6,7 @@ Describe "Get-FormatData" -Tags "CI" {
It "Should return an object[] as the return type" {
$result = Get-FormatData
,$result | Should -BeOfType "System.Object[]"
,$result | Should -BeOfType System.Object[]
}
}

View file

@ -25,12 +25,12 @@ Describe "Get-Member" -Tags "CI" {
$e = "anoeduntodeu" #test strings
$f = 'asntoheusth' #test strings
$a | Should -BeOfType 'Int32'
$b | Should -BeOfType 'Double'
$c | Should -BeOfType 'Boolean'
, $d | Should -BeOfType 'Object[]'
$e | Should -BeOfType 'String'
$f | Should -BeOfType 'String'
$a | Should -BeOfType Int32
$b | Should -BeOfType Double
$c | Should -BeOfType Boolean
, $d | Should -BeOfType Object[]
$e | Should -BeOfType String
$f | Should -BeOfType String
}
It "Should be able to be called on a newly created PSObject" {

View file

@ -132,7 +132,7 @@ Describe "Get-Random" -Tags "CI" {
It "Should return an array " {
$randomNumber = Get-Random -InputObject 1, 2, 3, 5, 8, 13 -Count 3
$randomNumber.Count | Should -Be 3
,$randomNumber | Should -BeOfType "System.Array"
,$randomNumber | Should -BeOfType System.Array
}
It "Should return three random numbers for array of 1,2,3,5,8,13 " {

View file

@ -7,7 +7,7 @@ Describe "Get-RunspaceDebug" -Tags "CI" {
It "Should return Microsoft.Powershell.Commands.PSRunspaceDebug as the return type" {
$rs = Get-RunspaceDebug
$rs | Should -Not -BeNullOrEmpty
$rs[0] | Should -BeOfType "Microsoft.PowerShell.Commands.PSRunspaceDebug"
$rs[0] | Should -BeOfType Microsoft.PowerShell.Commands.PSRunspaceDebug
}
}
}

View file

@ -12,10 +12,10 @@ Describe "Get-Unique DRT Unit Tests" -Tags "CI" {
$results[2] | Should -BeExactly "ba"
$results[3] | Should -BeExactly "BA"
$results[0] | Should -BeOfType "System.String"
$results[1] | Should -BeOfType "System.String"
$results[2] | Should -BeOfType "System.String"
$results[3] | Should -BeOfType "System.String"
$results[0] | Should -BeOfType System.String
$results[1] | Should -BeOfType System.String
$results[2] | Should -BeOfType System.String
$results[3] | Should -BeOfType System.String
}
}
@ -35,7 +35,7 @@ Describe "Get-Unique" -Tags "CI" {
It "Should output an array" {
$result = Get-Unique -InputObject $sortedList1
$result | Should -Not -BeNullOrEmpty
,$result | Should -BeOfType "System.Array"
,$result | Should -BeOfType System.Array
}
It "Should output an array of unchanged items when the InputObject switch is used" {

View file

@ -19,11 +19,11 @@ Describe "Get-Uptime" -Tags "CI" {
}
It "Get-Uptime return timespan (default -Timespan)" {
$upt = Get-Uptime
$upt | Should -BeOfType "Timespan"
$upt | Should -BeOfType Timespan
}
It "Get-Uptime -Since return DateTime" {
$upt = Get-Uptime -Since
$upt | Should -BeOfType "DateTime"
$upt | Should -BeOfType DateTime
}
It "Get-Uptime throw if IsHighResolution == false" {
# Enable the test hook

View file

@ -9,7 +9,7 @@ Describe "Group-Object DRT Unit Tests" -Tags "CI" {
$results.Group.Count | Should -Be 4
$results.Name | Should -Be aA,AA
$results.Group | Should -Be aA,aA,AA,AA
,$results | Should -BeOfType "System.Array"
,$results | Should -BeOfType System.Array
}
}
@ -46,13 +46,13 @@ Describe "Group-Object" -Tags "CI" {
It "Should return object of 'GroupInfo' type" {
$actualParam = Group-Object -InputObject $testObject
$actualParam | Should -BeOfType "Microsoft.PowerShell.Commands.GroupInfo"
$actualParam | Should -BeOfType Microsoft.PowerShell.Commands.GroupInfo
}
It "Should output an array when piped input is used" {
$actual = $testObject | Group-Object
,$actual | Should -BeOfType "System.Array"
,$actual | Should -BeOfType System.Array
}
It "Should have the same output between the group alias and the group-object cmdlet" {
@ -89,7 +89,7 @@ Describe "Group-Object" -Tags "CI" {
$actual = $testObject | Group-Object -AsHashTable
$actual | Should -Not -BeNullOrEmpty
$actual | Should -BeOfType "System.Collections.Hashtable"
$actual | Should -BeOfType System.Collections.Hashtable
}
It "Should be able to access when output as hash table" {
@ -187,7 +187,7 @@ Describe "Check 'Culture' parameter in order object cmdlets (Group-Object, Sort-
)
$Result = $capitonyms | Group-Object -Property Capitonym -AsHashTable -CaseSensitive
$Result | Should -BeOfType [HashTable]
$Result | Should -BeOfType HashTable
$Result.Keys | Should -BeIn @( 'Bill', 'bill' )
}
}

View file

@ -268,7 +268,7 @@ Describe "Json Tests" -Tags "Feature" {
$json = "[1,2,3,4,5,6]"
$result = ConvertFrom-Json $json
$result.Count | Should -Be 6
,$result | Should -BeOfType "System.Array"
,$result | Should -BeOfType System.Array
}
It "ConvertFrom-Json with a float value" {

View file

@ -4,7 +4,7 @@ Describe "New-TimeSpan DRT Unit Tests" -Tags "CI" {
It "Should works proper with new-timespan"{
$results = New-TimeSpan -Days 10 -Hours 10 -Minutes 10 -Seconds 10
$results | Should -BeOfType "System.Timespan"
$results | Should -BeOfType System.Timespan
$results.Days | Should -Be 10
$results.Hours | Should -Be 10
$results.Minutes | Should -Be 10
@ -16,7 +16,7 @@ Describe "New-TimeSpan" -Tags "CI" {
It "Should be able to create a new timespan object" {
New-Variable -Name testObject -Value $(New-TimeSpan)
$testObject | Should -BeOfType "System.Timespan"
$testObject | Should -BeOfType System.Timespan
}
Context "Core Functionality Tests" {

View file

@ -5,7 +5,7 @@ Describe "Out-String DRT Unit Tests" -Tags "CI" {
It "check display of properties with names containing wildcard characters" {
$results = new-object psobject | add-member -passthru noteproperty 'name with square brackets: [0]' 'myvalue' | out-string
$results.Length | Should -BeGreaterThan 1
$results | Should -BeOfType "System.String"
$results | Should -BeOfType System.String
$results.Contains("myvalue") | Should -BeTrue
$results.Contains("name with square brackets: [0]") | Should -BeTrue
}
@ -22,14 +22,14 @@ Describe "Out-String" -Tags "CI" {
$testArray = "a", " b"
$testArray | Out-String | Should -BeExactly "a$nl b$nl"
,$($testArray | Out-String) | Should -BeOfType "System.String"
,$($testArray | Out-String) | Should -BeOfType System.String
}
It "Should be able to return an array of strings using the stream switch" {
$testInput = "a", "b"
,$($testInput | Out-String) | Should -BeOfType "System.String"
,$($testInput | Out-String -Stream) | Should -BeOfType "System.Array"
,$($testInput | Out-String) | Should -BeOfType System.String
,$($testInput | Out-String -Stream) | Should -BeOfType System.Array
}
It "Should send all objects through a pipeline when not using the stream switch" {

View file

@ -23,17 +23,17 @@ Describe "Select-String" -Tags "CI" {
it "Should return an array data type when multiple matches are found" {
$result = $testinputtwo | Select-String -Pattern "hello"
,$result | Should -BeOfType "System.Array"
,$result | Should -BeOfType System.Array
}
it "Should return an object type when one match is found" {
$result = $testinputtwo | Select-String -Pattern "hello" -CaseSensitive
,$result | Should -BeOfType "System.Object"
,$result | Should -BeOfType System.Object
}
it "Should return matchinfo type" {
$result = $testinputtwo | Select-String -Pattern "hello" -CaseSensitive
,$result | Should -BeOfType "Microsoft.PowerShell.Commands.MatchInfo"
,$result | Should -BeOfType Microsoft.PowerShell.Commands.MatchInfo
}
it "Should be called without an error using ca for casesensitive " {
@ -58,7 +58,7 @@ Describe "Select-String" -Tags "CI" {
it "Should return system.object when the input object switch is used on a collection" {
$result = Select-String -InputObject "some stuff", "other stuff" -pattern "other"
,$result | Should -BeOfType "System.Object"
,$result | Should -BeOfType System.Object
}
it "Should return null or empty when the input object switch is used on a collection and the pattern does not exist" {
@ -66,7 +66,7 @@ Describe "Select-String" -Tags "CI" {
}
it "Should return a bool type when the quiet switch is used" {
,($testinputtwo | Select-String -Quiet "hello" -CaseSensitive) | Should -BeOfType "System.Boolean"
,($testinputtwo | Select-String -Quiet "hello" -CaseSensitive) | Should -BeOfType System.Boolean
}
it "Should be true when select string returns a positive result when the quiet switch is used" {
@ -131,7 +131,7 @@ Describe "Select-String" -Tags "CI" {
It "Should return a string type when -Raw is used" {
$result = $testinputtwo | Select-String -Pattern "hello" -CaseSensitive -Raw
$result | Should -BeOfType "System.String"
$result | Should -BeOfType System.String
}
It "Should return ParameterBindingException when -Raw and -Quiet are used together" {
@ -153,13 +153,13 @@ Describe "Select-String" -Tags "CI" {
It "Should return an object when a match is found is the file on only one line" {
$result = Select-String $testInputFile -Pattern "string"
,$result | Should -BeOfType "System.Object"
,$result | Should -BeOfType System.Object
}
It "Should return an array when a match is found is the file on several lines" {
$result = Select-String $testInputFile -Pattern "in"
,$result | Should -BeOfType "System.Array"
$result[0] | Should -BeOfType "Microsoft.PowerShell.Commands.MatchInfo"
,$result | Should -BeOfType System.Array
$result[0] | Should -BeOfType Microsoft.PowerShell.Commands.MatchInfo
}
It "Should return the name of the file and the string that 'string' is found if there is only one lines that has a match" {

View file

@ -698,7 +698,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$result = ExecuteWebCommand -command $command
$result.Error.ErrorDetails.Message | Should -Be $query.body
$result.Error.Exception | Should -BeOfType 'Microsoft.PowerShell.Commands.HttpResponseException'
$result.Error.Exception | Should -BeOfType Microsoft.PowerShell.Commands.HttpResponseException
$result.Error.Exception.Response.StatusCode | Should -Be 418
$result.Error.Exception.Response.ReasonPhrase | Should -Be $query.responsephrase
$result.Error.Exception.Message | Should -Match ": 418 \($($query.responsephrase)\)\."
@ -891,7 +891,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$command = "Invoke-WebRequest -Uri '$uri' -Headers @{Authorization = 'foo'}"
$response = ExecuteWebCommand -command $command
$response.Error.Exception | Should -BeOfType 'Microsoft.PowerShell.Commands.HttpResponseException'
$response.Error.Exception | Should -BeOfType Microsoft.PowerShell.Commands.HttpResponseException
$response.Error.Exception.Response.StatusCode | Should -Be $StatusCode
$response.Error.Exception.Response.Headers.Location | Should -BeNullOrEmpty
}
@ -1064,7 +1064,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest detects charset meta value when newlines are encountered in the element." {
@ -1078,7 +1078,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest detects charset meta value when the attribute value is unquoted." {
@ -1092,7 +1092,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest detects http-equiv charset meta value when the ContentType header does not define it." {
@ -1106,7 +1106,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest detects http-equiv charset meta value newlines are encountered in the element." {
@ -1120,7 +1120,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest ignores meta charset value when Content-Type header defines it." {
@ -1135,7 +1135,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest honors non-utf8 charsets in the Content-Type header" {
@ -1150,7 +1150,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest defaults to iso-8859-1 when an unsupported/invalid charset is declared" {
@ -1164,7 +1164,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest defaults to iso-8859-1 when an unsupported/invalid charset is declared using http-equiv" {
@ -1178,7 +1178,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
}
It "Verifies Invoke-WebRequest defaults to UTF8 on application/json when no charset is present" {
@ -1193,7 +1193,7 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
$response.Error | Should -BeNullOrEmpty
$response.Output.Encoding.EncodingName | Should -Be $expectedEncoding.EncodingName
$response.Output | Should -BeOfType 'Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject'
$response.Output | Should -BeOfType Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject
$response.Output.Content | Should -BeExactly $query.body
}
}
@ -2250,7 +2250,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
$result = ExecuteWebCommand -command $command
$result.Error.ErrorDetails.Message | Should -Be $query.body
$result.Error.Exception | Should -BeOfType 'Microsoft.PowerShell.Commands.HttpResponseException'
$result.Error.Exception | Should -BeOfType Microsoft.PowerShell.Commands.HttpResponseException
$result.Error.Exception.Response.StatusCode | Should -Be 418
$result.Error.Exception.Response.ReasonPhrase | Should -Be $query.responsephrase
$result.Error.Exception.Message | Should -Match ": 418 \($($query.responsephrase)\)\."
@ -2451,7 +2451,7 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
$command = "Invoke-RestMethod -Uri '$uri' -Headers @{Authorization = 'foo'}"
$response = ExecuteWebCommand -command $command
$response.Error.Exception | Should -BeOfType 'Microsoft.PowerShell.Commands.HttpResponseException'
$response.Error.Exception | Should -BeOfType Microsoft.PowerShell.Commands.HttpResponseException
$response.Error.Exception.Response.StatusCode | Should -Be $StatusCode
$response.Error.Exception.Response.Headers.Location | Should -BeNullOrEmpty
}

View file

@ -3,10 +3,10 @@
Describe "Write-Error Tests" -Tags "CI" {
It "Should be works with command: write-error myerrortext" {
$e = Write-Error myerrortext 2>&1
$e | Should -BeOfType 'System.Management.Automation.ErrorRecord'
$e | Should -BeOfType System.Management.Automation.ErrorRecord
#Exception verification
$e.Exception | Should -BeOfType 'Microsoft.PowerShell.Commands.WriteErrorException'
$e.Exception | Should -BeOfType Microsoft.PowerShell.Commands.WriteErrorException
$e.Exception.Message | Should -Be 'myerrortext'
$e.Exception.Data.Count | Should -Be 0
$e.Exception.InnerException | Should -BeNullOrEmpty
@ -35,10 +35,10 @@ Describe "Write-Error Tests" -Tags "CI" {
$exception = New-Object -TypeName System.ArgumentNullException -ArgumentList paramname
$e = Write-Error -Message myerrortext -Exception $exception -ErrorId myerrorid -Category syntaxerror -TargetObject TargetObject -CategoryActivity myactivity -CategoryReason myreason -CategoryTargetName mytargetname -CategoryTargetType mytargettype -RecommendedAction myrecommendedaction 2>&1
$e | Should -Not -BeNullOrEmpty
$e | Should -BeOfType 'System.Management.Automation.ErrorRecord'
$e | Should -BeOfType System.Management.Automation.ErrorRecord
#Exception verification
$e.Exception | Should -BeOfType 'System.ArgumentNullException'
$e.Exception | Should -BeOfType System.ArgumentNullException
$e.Exception.ParamName | Should -Be 'paramname'
$e.Exception.Data.Count | Should -Be 0
$e.Exception.InnerException | Should -BeNullOrEmpty

View file

@ -178,7 +178,7 @@ Describe "CliXml test" -Tags "CI" {
$cred | Export-Clixml -Path $path
$cred = Import-Clixml -Path $path
$cred.UserName | Should -BeExactly "Foo"
$cred.Password | Should -BeOfType "System.Security.SecureString"
$cred.Password | Should -BeOfType System.Security.SecureString
}
}
}

View file

@ -471,7 +471,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
it "Resource with embedded resource not supported and a warning should be produced" {
Set-ItResult -Pending -Because "Test is unreliable in release automation."
if (!(Test-IsInvokeDscResourceEnable)) {
Set-ItResult -Skipped -Because "Feature not enabled"
}
@ -530,14 +530,14 @@ Describe "Test PSDesiredStateConfiguration" -tags CI {
$result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method Get -Property @{ Name = 'PsDscResources' }
$result | Should -Not -BeNullOrEmpty
$result.Author | Should -BeLike 'Microsoft*'
$result.InstallationPolicy | Should -BeOfType [string]
$result.Guid | Should -BeOfType [Guid]
$result.InstallationPolicy | Should -BeOfType string
$result.Guid | Should -BeOfType Guid
$result.Ensure | Should -Be 'Present'
$result.Name | Should -Be 'PsDscResources'
$result.Description | Should -BeLike 'This*DSC*'
$result.InstalledVersion | Should -BeOfType [Version]
$result.InstalledVersion | Should -BeOfType Version
$result.ModuleBase | Should -BeLike '*PSDscResources*'
$result.Repository | Should -BeOfType [string]
$result.Repository | Should -BeOfType string
$result.ModuleType | Should -Be 'Manifest'
}
}

View file

@ -41,15 +41,15 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
}
It 'Can set command breakpoints' {
$Host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist') | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
$Host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist') | Should -BeOfType System.Management.Automation.CommandBreakpoint
}
It 'Can set variable breakpoints' {
$Host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }) | Should -BeOfType [System.Management.Automation.VariableBreakpoint]
$Host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }) | Should -BeOfType System.Management.Automation.VariableBreakpoint
}
It 'Can set line breakpoints' {
$Host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }) | Should -BeOfType [System.Management.Automation.LineBreakpoint]
$Host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }) | Should -BeOfType System.Management.Automation.LineBreakpoint
}
It 'Can get breakpoints' {
@ -101,15 +101,15 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
}
It 'Can set command breakpoints' {
$jobRunspace.Debugger.SetCommandBreakpoint('Write-Verbose', { break }) | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
$jobRunspace.Debugger.SetCommandBreakpoint('Write-Verbose', { break }) | Should -BeOfType System.Management.Automation.CommandBreakpoint
}
It 'Can set variable breakpoints' {
$jobRunspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { break }) | Should -BeOfType [System.Management.Automation.VariableBreakpoint]
$jobRunspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { break }) | Should -BeOfType System.Management.Automation.VariableBreakpoint
}
It 'Can set line breakpoints' {
$jobRunspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { break }) | Should -BeOfType [System.Management.Automation.LineBreakpoint]
$jobRunspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { break }) | Should -BeOfType System.Management.Automation.LineBreakpoint
}
It 'Can get breakpoints' {
@ -212,15 +212,15 @@ Describe 'Breakpoint SDK Unit Tests' -Tags 'CI' {
}
It 'Can set command breakpoints' {
$Host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist', $null, $null, $runspace.Id) | Should -BeOfType [System.Management.Automation.CommandBreakpoint]
$Host.Runspace.Debugger.SetCommandBreakpoint('Test-ThisCommandDoesNotExist', $null, $null, $runspace.Id) | Should -BeOfType System.Management.Automation.CommandBreakpoint
}
It 'Can set variable breakpoints' {
$Host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }, $null, $runspace.Id) | Should -BeOfType [System.Management.Automation.VariableBreakpoint]
$Host.Runspace.Debugger.SetVariableBreakpoint('DebugPreference', 'ReadWrite', { continue }, $null, $runspace.Id) | Should -BeOfType System.Management.Automation.VariableBreakpoint
}
It 'Can set line breakpoints' {
$Host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }, $runspace.Id) | Should -BeOfType [System.Management.Automation.LineBreakpoint]
$Host.Runspace.Debugger.SetLineBreakpoint($PSCommandPath, 1, 1, { continue }, $runspace.Id) | Should -BeOfType System.Management.Automation.LineBreakpoint
}
It 'Can get breakpoints' {

View file

@ -91,8 +91,8 @@ try {
# in a runspace that has not been opened.
$err = { $ps.AddScript('1+1').InvokeAsync() } | Should -Throw -ErrorId "InvalidRunspaceStateException" -PassThru
$err.Exception | Should -BeOfType "System.Management.Automation.MethodInvocationException"
$err.Exception.InnerException | Should -BeOfType "System.Management.Automation.Runspaces.InvalidRunspaceStateException"
$err.Exception | Should -BeOfType System.Management.Automation.MethodInvocationException
$err.Exception.InnerException | Should -BeOfType System.Management.Automation.Runspaces.InvalidRunspaceStateException
$err.Exception.InnerException.CurrentState | Should -Be 'BeforeOpen'
$err.Exception.InnerException.ExpectedState | Should -Be 'Opened'
} finally {

View file

@ -45,7 +45,7 @@ Describe "Command Discovery tests" -Tags "CI" {
$commands.Count | Should -Be 1
$aliasResult = $commands -as [System.Management.Automation.AliasInfo]
$aliasResult | Should -BeOfType [System.Management.Automation.AliasInfo]
$aliasResult | Should -BeOfType System.Management.Automation.AliasInfo
$aliasResult.Name | Should -Be 'AliasCommandDiscoveryTest'
}

View file

@ -70,7 +70,7 @@ Describe "Telemetry for shell startup" -Tag CI {
$uuidPath | Should -Exist
(Get-ChildItem -Path $uuidPath).Length | Should -Be 16
[byte[]]$newBytes = Get-Content -AsByteStream -Path $uuidPath
[System.Guid]::New($newBytes) | Should -BeOfType [System.Guid]
[System.Guid]::New($newBytes) | Should -BeOfType System.Guid
}
It "Should not create a telemetry file if one already exists and telemetry is opted in" {
@ -96,7 +96,7 @@ Describe "Telemetry for shell startup" -Tag CI {
[System.IO.File]::WriteAllBytes($uuidPath, $badBytes)
& $PWSH -NoProfile -Command "exit"
[byte[]]$nb = Get-Content -AsByteStream -Path $uuidPath
[System.Guid]::New($nb) | Should -BeOfType [System.Guid]
[System.Guid]::New($nb) | Should -BeOfType System.Guid
}
It "Should not create a new telemetry file if the current one has a valid guid and is larger than 16 bytes" {

View file

@ -162,7 +162,7 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows {
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]
$result.GetCimSessionInstanceId() | Should -BeOfType guid
}
}

View file

@ -27,37 +27,37 @@ Describe "Built-in type information tests" -Tag "CI" {
$typeData | Should -Not -BeNullOrEmpty
$typeData.Members.Count | Should -BeExactly 6
$typeData.Members['Size'] | Should -BeOfType "System.Management.Automation.Runspaces.ScriptPropertyData"
$typeData.Members['Size'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Size'].GetScriptBlock.ToString() | Should -BeExactly '$this.ModuleMemorySize / 1024'
$typeData.Members['Size'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Size'].IsHidden | Should -BeFalse
$typeData.Members['Size'].Name | Should -Be "Size"
$typeData.Members['Company'] | Should -BeOfType "System.Management.Automation.Runspaces.ScriptPropertyData"
$typeData.Members['Company'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Company'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.CompanyName'
$typeData.Members['Company'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Company'].IsHidden | Should -BeFalse
$typeData.Members['Company'].Name | Should -Be "Company"
$typeData.Members['FileVersion'] | Should -BeOfType "System.Management.Automation.Runspaces.ScriptPropertyData"
$typeData.Members['FileVersion'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['FileVersion'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.FileVersion'
$typeData.Members['FileVersion'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['FileVersion'].IsHidden | Should -BeFalse
$typeData.Members['FileVersion'].Name | Should -Be "FileVersion"
$typeData.Members['ProductVersion'] | Should -BeOfType "System.Management.Automation.Runspaces.ScriptPropertyData"
$typeData.Members['ProductVersion'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['ProductVersion'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.ProductVersion'
$typeData.Members['ProductVersion'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['ProductVersion'].IsHidden | Should -BeFalse
$typeData.Members['ProductVersion'].Name | Should -Be "ProductVersion"
$typeData.Members['Description'] | Should -BeOfType "System.Management.Automation.Runspaces.ScriptPropertyData"
$typeData.Members['Description'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Description'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.FileDescription'
$typeData.Members['Description'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Description'].IsHidden | Should -BeFalse
$typeData.Members['Description'].Name | Should -Be "Description"
$typeData.Members['Product'] | Should -BeOfType "System.Management.Automation.Runspaces.ScriptPropertyData"
$typeData.Members['Product'] | Should -BeOfType System.Management.Automation.Runspaces.ScriptPropertyData
$typeData.Members['Product'].GetScriptBlock.ToString() | Should -BeExactly '$this.FileVersionInfo.ProductName'
$typeData.Members['Product'].SetScriptBlock | Should -BeNullOrEmpty
$typeData.Members['Product'].IsHidden | Should -BeFalse
@ -83,7 +83,7 @@ Describe "Built-in type information tests" -Tag "CI" {
$typeData | Should -Not -BeNullOrEmpty
$typeData.Members.Count | Should -BeExactly 1
$typeData.Members['Flags'] | Should -BeOfType "System.Management.Automation.Runspaces.CodePropertyData"
$typeData.Members['Flags'] | Should -BeOfType System.Management.Automation.Runspaces.CodePropertyData
$typeData.Members['Flags'].IsHidden | Should -BeFalse
$typeData.Members['Flags'].Name | Should -Be "Flags"
@ -100,7 +100,7 @@ Describe "Built-in type information tests" -Tag "CI" {
$typeData.DefaultKeyPropertySet | Should -BeNullOrEmpty
$typeData.SerializationMethod | Should -BeExactly "SpecificProperties"
$typeData.PropertySerializationSet | Should -BeOfType "System.Management.Automation.Runspaces.PropertySetData"
$typeData.PropertySerializationSet | Should -BeOfType System.Management.Automation.Runspaces.PropertySetData
[string]::Join(",", $typeData.PropertySerializationSet.ReferencedProperties) | Should -BeExactly "Position,Flags,HelpMessage"
}

View file

@ -167,8 +167,8 @@ Describe "Experimental Feature Basic Tests - Feature-Disabled" -tags "CI" {
## Common parameters + '-Name' and '-ConfigName' (dynamic parameters are triggered)
$command.Parameters.Count | Should -Be ($CommonParameterCount + 2)
$command.Parameters["ConfigName"].Attributes.Count | Should -Be 2
$command.Parameters["ConfigName"].Attributes[0] | Should -BeOfType [parameter]
$command.Parameters["ConfigName"].Attributes[1] | Should -BeOfType [ValidateNotNullOrEmpty]
$command.Parameters["ConfigName"].Attributes[0] | Should -BeOfType parameter
$command.Parameters["ConfigName"].Attributes[1] | Should -BeOfType ValidateNotNullOrEmpty
$command.Parameters.ContainsKey("ConfigFile") | Should -BeFalse
}
@ -365,8 +365,8 @@ Describe "Experimental Feature Basic Tests - Feature-Enabled" -Tag "CI" {
## Common parameters + '-Name' and '-ConfigFile' (dynamic parameters are triggered)
$command.Parameters.Count | Should -Be ($CommonParameterCount + 2)
$command.Parameters["ConfigFile"].Attributes.Count | Should -Be 2
$command.Parameters["ConfigFile"].Attributes[0] | Should -BeOfType [parameter]
$command.Parameters["ConfigFile"].Attributes[1] | Should -BeOfType [ValidateNotNullOrEmpty]
$command.Parameters["ConfigFile"].Attributes[0] | Should -BeOfType parameter
$command.Parameters["ConfigFile"].Attributes[1] | Should -BeOfType ValidateNotNullOrEmpty
$command.Parameters.ContainsKey("ConfigName") | Should -BeFalse
}

View file

@ -4,7 +4,7 @@
Describe 'Tests for $ErrorView' -Tag CI {
It '$ErrorView is an enum' {
$ErrorView | Should -BeOfType [System.Management.Automation.ErrorView]
$ErrorView | Should -BeOfType System.Management.Automation.ErrorView
}
It '$ErrorView should have correct default value' {

View file

@ -28,7 +28,7 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
$credential = [PSCredential]::new('username', $password)
$err = ({New-PSSession -ComputerName 'localhost' -Credential $credential -Authentication Basic} | Should -Throw -PassThru -ErrorId 'System.Management.Automation.Remoting.PSRemotingDataStructureException,Microsoft.PowerShell.Commands.NewPSSessionCommand')
$err.Exception | Should -BeOfType [System.Management.Automation.Remoting.PSRemotingTransportException]
$err.Exception | Should -BeOfType System.Management.Automation.Remoting.PSRemotingTransportException
# Should be PSRemotingErrorId.ConnectFailed
# Ensures we are looking at the expected instance
$err.Exception.ErrorCode | Should -Be 801
@ -48,7 +48,7 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") {
# NOTE: The connection is expected to fail but not with a ConnectFailed exception
$uri = "https://localhost"
New-PSSession -Uri $uri -Credential $credential -Authentication Basic -ErrorVariable err
$err.Exception | Should -BeOfType [System.Management.Automation.Remoting.PSRemotingTransportException]
$err.Exception | Should -BeOfType System.Management.Automation.Remoting.PSRemotingTransportException
$err.FullyQualifiedErrorId | Should -Be '1,PSSessionOpenFailed'
$err.Exception.HResult | Should -Be 0x80131501
}

View file

@ -34,7 +34,7 @@ Describe "SSH Remoting API Tests" -Tags "Feature" {
$rs = [runspacefactory]::CreateRunspace($sshConnectionInfo)
$e = { $rs.Open() } | Should -Throw -PassThru
$e.Exception.InnerException.InnerException | Should -BeOfType "System.IO.FileNotFoundException"
$e.Exception.InnerException.InnerException | Should -BeOfType System.IO.FileNotFoundException
}
It "SSHConnectionInfo should throw argument exception for invalid port (non 16bit uint)" {

View file

@ -10,7 +10,7 @@ try {
}
It "The SessionOption type can be created" {
$result = [Microsoft.WSMan.Management.SessionOption]::new()
$result | Should -BeOfType "Microsoft.WSMan.Management.SessionOption"
$result | Should -BeOfType Microsoft.WSMan.Management.SessionOption
}
It "The SessionOption type has the proper properties when created with the default constructor" {
$result = [Microsoft.WSMan.Management.SessionOption]::new()