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

This commit is contained in:
xtqqczze authored and Dongbo Wang committed 2020-01-24 11:00:37 -08:00
1 parent a7a2b12336
commit 920b671fb4
68 files changed
+216 -216

No files matched your search

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