From eb3f1cd914fac72d3391f6f637b066f97640080c Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Fri, 2 Mar 2018 12:43:18 -0800 Subject: [PATCH 1/7] [Feature] Use new Pester syntax: -Parameter for Pester tests in engine. --- .../engine/Api/BasicEngine.Tests.ps1 | 12 +- .../engine/Api/GetNewClosure.Tests.ps1 | 8 +- .../engine/Api/InitialSessionState.Tests.ps1 | 28 +- .../engine/Api/LanguagePrimitive.Tests.ps1 | 12 +- .../engine/Api/ProxyCommand.Tests.ps1 | 20 +- .../engine/Api/Serialization.Tests.ps1 | 14 +- .../engine/Api/TypeInference.Tests.ps1 | 328 +++++++++--------- .../engine/Basic/Assembly.LoadFrom.ps1 | 12 +- .../engine/Basic/CommandDiscovery.Tests.ps1 | 22 +- .../engine/Basic/Credential.Tests.ps1 | 2 +- .../engine/Basic/DefaultCommands.Tests.ps1 | 10 +- .../engine/Basic/Encoding.Tests.ps1 | 12 +- .../engine/Basic/PropertyAccessor.Tests.ps1 | 14 +- .../engine/Basic/SemanticVersion.Tests.ps1 | 148 ++++---- .../engine/Basic/ValidateAttributes.Tests.ps1 | 44 +-- .../powershell/engine/COM/COM.Basic.Tests.ps1 | 22 +- test/powershell/engine/Cdxml/Cdxml.Tests.ps1 | 64 ++-- test/powershell/engine/ETS/Adapter.Tests.ps1 | 170 ++++----- .../engine/ETS/CimAdapter.Tests.ps1 | 30 +- .../Help/HelpSystem.OnlineHelp.Tests.ps1 | 6 +- .../engine/Help/HelpSystem.Tests.ps1 | 40 +-- .../engine/Help/UpdatableHelpSystem.Tests.ps1 | 8 +- test/powershell/engine/Job/Jobs.Tests.ps1 | 60 ++-- .../engine/Module/ModulePath.Tests.ps1 | 22 +- .../engine/Module/NewModuleManifest.Tests.ps1 | 10 +- .../Module/SubmodulePathInManifest.Tests.ps1 | 4 +- .../Module/TestModuleManifest.Tests.ps1 | 16 +- .../BooleanParameterDCR.Tests.ps1 | 10 +- .../NullableBooleanDCR.Tests.ps1 | 12 +- .../ParameterBinding.Tests.ps1 | 102 +++--- .../StaticParameterBinder.Tests.ps1 | 48 +-- .../InvokeCommandRemoteDebug.Tests.ps1 | 10 +- .../Remoting/RemoteSession.Basic.Tests.ps1 | 32 +- .../Remoting/RoleCapabilityFiles.Tests.ps1 | 6 +- .../engine/Remoting/SSHRemotingAPI.Tests.ps1 | 4 +- .../Remoting/SSHRemotingCmdlets.Tests.ps1 | 4 +- .../engine/Remoting/SessionOption.Tests.ps1 | 44 +-- .../engine/ResourceValidation/TestRunner.ps1 | 4 +- 38 files changed, 707 insertions(+), 707 deletions(-) diff --git a/test/powershell/engine/Api/BasicEngine.Tests.ps1 b/test/powershell/engine/Api/BasicEngine.Tests.ps1 index 10931fc9e32..6d92bed8d1d 100644 --- a/test/powershell/engine/Api/BasicEngine.Tests.ps1 +++ b/test/powershell/engine/Api/BasicEngine.Tests.ps1 @@ -3,7 +3,7 @@ Describe 'Basic engine APIs' -Tags "CI" { Context 'powershell::Create' { It 'can create default instance' { - [powershell]::Create() | Should Not Be $null + [powershell]::Create() | Should -Not -Be $null } It "can load the default snapin 'Microsoft.WSMan.Management'" -skip:(-not $IsWindows) { @@ -11,15 +11,15 @@ Describe 'Basic engine APIs' -Tags "CI" { $ps.AddScript("Get-Command -Name Test-WSMan") > $null $result = $ps.Invoke() - $result.Count | Should Be 1 - $result[0].Source | Should Be "Microsoft.WSMan.Management" + $result.Count | Should -Be 1 + $result[0].Source | Should -Be "Microsoft.WSMan.Management" } } Context 'executioncontext' { It 'args are passed correctly' { $result = $ExecutionContext.SessionState.InvokeCommand.InvokeScript('"`$args:($args); `$input:($input)"', 1, 2, 3) - $result | Should BeExactly '$args:(1 2 3); $input:()' + $result | Should -BeExactly '$args:(1 2 3); $input:()' } } } @@ -41,9 +41,9 @@ exit $expect = "powershell process exits in 5 seconds" if (-not $process.HasExited) { Stop-Process -InputObject $process -Force -ErrorAction SilentlyContinue - "powershell process doesn't exit in 5 seconds" | Should Be $expect + "powershell process doesn't exit in 5 seconds" | Should -Be $expect } else { - $expect | Should Be $expect + $expect | Should -Be $expect } } } diff --git a/test/powershell/engine/Api/GetNewClosure.Tests.ps1 b/test/powershell/engine/Api/GetNewClosure.Tests.ps1 index 7868a25f8e4..c637fe806c5 100644 --- a/test/powershell/engine/Api/GetNewClosure.Tests.ps1 +++ b/test/powershell/engine/Api/GetNewClosure.Tests.ps1 @@ -32,13 +32,13 @@ Describe "ScriptBlock.GetNewClosure()" -tags "CI" { } It "Parameter attributes should not get evaluated again in GetNewClosure - SimpleFunction" { - SimpleFunction_GetNewClosure | Should Be "OK" + SimpleFunction_GetNewClosure | Should -Be "OK" } It "Parameter attributes should not get evaluated again in GetNewClosure - ScriptCmdlet" { $result = ScriptCmdlet_GetNewClosure - $result.Count | Should Be 2 - $result[0] | Should Be 4 - $result[1] | Should Be "" + $result.Count | Should -Be 2 + $result[0] | Should -Be 4 + $result[1] | Should -Be "" } } diff --git a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 index 5db70192ecd..096a8d0dd5a 100644 --- a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 +++ b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 @@ -28,33 +28,33 @@ Describe "InitialSessionState capacity" -Tags CI { } It "function capacity in initial session state should not be limited" { - $ps.AddCommand('f4999').Invoke() | Should Be "fn f4999" - $ps.Streams.Error | Should Be $null + $ps.AddCommand('f4999').Invoke() | Should -Be "fn f4999" + $ps.Streams.Error | Should -Be $null } It "alias capacity in initial session state should not be limited" { - $ps.AddCommand('a4999').Invoke() | Should Be "fn f4999" - $ps.Streams.Error | Should Be $null + $ps.AddCommand('a4999').Invoke() | Should -Be "fn f4999" + $ps.Streams.Error | Should -Be $null } It "variable capacity in initial session state should not be limited" { - $ps.AddScript('$v4999').Invoke() | Should Be "var v4999" - $ps.Streams.Error | Should Be $null + $ps.AddScript('$v4999').Invoke() | Should -Be "var v4999" + $ps.Streams.Error | Should -Be $null } It "function capacity should not be limited after runspace is opened" { - $ps.AddScript('function f5000 { "in f5000" } f5000').Invoke() | Should Be "in f5000" - $ps.Streams.Error | Should Be $null + $ps.AddScript('function f5000 { "in f5000" } f5000').Invoke() | Should -Be "in f5000" + $ps.Streams.Error | Should -Be $null } It "variable capacity should not be limited after runspace is opened" { - $ps.AddScript('$v5000 = "var v5000"; $v5000').Invoke() | Should Be "var v5000" - $ps.Streams.Error | Should Be $null + $ps.AddScript('$v5000 = "var v5000"; $v5000').Invoke() | Should -Be "var v5000" + $ps.Streams.Error | Should -Be $null } It "alias capacity should not be limited after runspace is opened" { - $ps.AddScript('New-Alias -Name a5000 -Value f1; a5000').Invoke() | Should Be "fn f1" - $ps.Streams.Error | Should Be $null + $ps.AddScript('New-Alias -Name a5000 -Value f1; a5000').Invoke() | Should -Be "fn f1" + $ps.Streams.Error | Should -Be $null } } @@ -91,7 +91,7 @@ Describe "TypeTable duplicate types in reused runspace InitialSessionState TypeT It "Verifies that a reused InitialSessionState object created from a TypeTable object does not have duplicate types" { - { $rs2.Open() } | Should Not Throw + { $rs2.Open() } | Should -Not -Throw } } @@ -123,7 +123,7 @@ Describe "TypeTable duplicate types in reused runspace InitialSessionState TypeT } catch { - $_.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should Be "ErrorsUpdatingTypes" + $_.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should -Be "ErrorsUpdatingTypes" } } } diff --git a/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 b/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 index 003d9ba262b..2eb18d0b192 100644 --- a/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 +++ b/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 @@ -4,32 +4,32 @@ Describe "Language Primitive Tests" -Tags "CI" { It "Equality comparison with string and non-numeric type should not be culture sensitive" { $date = [datetime]'2005,3,10' $val = [System.Management.Automation.LanguagePrimitives]::Equals($date, "3/10/2005") - $val | Should Be $true + $val | Should -Be $true } It "Test conversion of an PSObject with Null Base Object to bool" { $mshObj = New-Object psobject - { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [bool]) } | Should Be $true + { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [bool]) } | Should -Be $true } It "Test conversion of an PSObject with Null Base Object to string" { $mshObj = New-Object psobject - { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [string]) -eq "" } | Should Be $true + { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [string]) -eq "" } | Should -Be $true } It "Test conversion of an PSObject with Null Base Object to object" { $mshObj = New-Object psobject - { $mshObj -eq [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [Object]) } | Should Be $true + { $mshObj -eq [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [Object]) } | Should -Be $true } It "Test Conversion of an IEnumerable to object[]" { $col = [System.Diagnostics.Process]::GetCurrentProcess().Modules $ObjArray = [System.Management.Automation.LanguagePrimitives]::ConvertTo($col, [object[]]) - $ObjArray.Length | Should Be $col.Count + $ObjArray.Length | Should -Be $col.Count } It "Casting recursive array to bool should not cause crash" { $a[0] = $a = [PSObject](,1) - [System.Management.Automation.LanguagePrimitives]::IsTrue($a) | Should Be $true + [System.Management.Automation.LanguagePrimitives]::IsTrue($a) | Should -Be $true } } diff --git a/test/powershell/engine/Api/ProxyCommand.Tests.ps1 b/test/powershell/engine/Api/ProxyCommand.Tests.ps1 index 61046788c92..1028a8fee75 100644 --- a/test/powershell/engine/Api/ProxyCommand.Tests.ps1 +++ b/test/powershell/engine/Api/ProxyCommand.Tests.ps1 @@ -102,26 +102,26 @@ Describe 'ProxyCommand Tests' -Tags "CI" { $helpObjText = NormalizeCRLF -helpObj $helpObj $newHelpObjText = NormalizeCRLF -helpObj $newHelpObj - $helpObjText | Should Be $newHelpObjText + $helpObjText | Should -Be $newHelpObjText $oldDespText = GetSectionText $helpObj.description $newDespText = GetSectionText $newHelpObj.description - $oldDespText | Should Be $newDespText + $oldDespText | Should -Be $newDespText $oldParameters = @($helpObj.parameters.parameter) $newParameters = @($newHelpObj.parameters.parameter) - $oldParameters.Length | Should Be $newParameters.Length - $oldParameters.name -join "," | Should Be ($newParameters.name -join ",") + $oldParameters.Length | Should -Be $newParameters.Length + $oldParameters.name -join "," | Should -Be ($newParameters.name -join ",") $oldExamples = @($helpObj.examples.example) $newExamples = @($newHelpObj.examples.example) - $oldExamples.Length | Should Be $newExamples.Length + $oldExamples.Length | Should -Be $newExamples.Length } It "Test generate proxy command" { $cmdInfo = Get-Command -Name Get-Content $cmdMetadata = [CommandMetadata]::new($cmdInfo) $proxyBody = [ProxyCommand]::Create($cmdMetadata, "--DummyHelpContent--") - $proxyBody | Should Match '--DummyHelpContent--' + $proxyBody | Should -Match '--DummyHelpContent--' $proxyBodySB = [scriptblock]::Create($proxyBody) Set-Item -Path function:\MyGetContent -Value $proxyBodySB @@ -129,7 +129,7 @@ Describe 'ProxyCommand Tests' -Tags "CI" { $expectedContent = "Hello World" Set-Content -Path $TestDrive\content.txt -Value $expectedContent -Encoding Unicode $myContent = MyGetContent -Path $TestDrive\content.txt -Encoding Unicode - $myContent | Should Be $expectedContent + $myContent | Should -Be $expectedContent } It "Test generate individual components" { @@ -171,12 +171,12 @@ End {{ $cmdMyProxyTest = Get-Command MyProxyTest $dyParam = $cmdMyProxyTest.Parameters.GetEnumerator() | Where-Object { $_.Value.IsDynamic } - $dyParam.Key | Should Be 'LastName' + $dyParam.Key | Should -Be 'LastName' $result = "Msg1", "Msg2" | MyProxyTest -Name Apple -LastName Last - $result | Should Be "Apple,Last - Msg1;Msg2" + $result | Should -Be "Apple,Last - Msg1;Msg2" $result = "Msg1", "Msg2" | MyProxyTest -Id 3 -LastName Last - $result | Should Be "3,Last - Msg1;Msg2" + $result | Should -Be "3,Last - Msg1;Msg2" } } diff --git a/test/powershell/engine/Api/Serialization.Tests.ps1 b/test/powershell/engine/Api/Serialization.Tests.ps1 index d7bf4709ff5..419c7b17d5b 100644 --- a/test/powershell/engine/Api/Serialization.Tests.ps1 +++ b/test/powershell/engine/Api/Serialization.Tests.ps1 @@ -33,14 +33,14 @@ Describe "Serialization Tests" -tags "CI" { It 'Test DateTimeUtc serialize and deserialize work as expected.' { $inputObject = [System.DateTime]::UtcNow; - SerializeAndDeserialize($inputObject) | Should be $inputObject + SerializeAndDeserialize($inputObject) | Should -Be $inputObject } It 'Test DateTime stamps serialize and deserialize work as expected.' { $objs = [System.DateTime]::MaxValue, [System.DateTime]::MinValue, [System.DateTime]::Today, (new-object System.DateTime), (new-object System.DateTime 123456789) foreach($inputObject in $objs) { - SerializeAndDeserialize($inputObject) | Should be $inputObject + SerializeAndDeserialize($inputObject) | Should -Be $inputObject } } @@ -50,7 +50,7 @@ Describe "Serialization Tests" -tags "CI" { foreach($uristring in $uristrings) { $inputObject = new-object System.Uri $uristring - SerializeAndDeserialize($inputObject) | Should be $inputObject + SerializeAndDeserialize($inputObject) | Should -Be $inputObject } } @@ -74,20 +74,20 @@ Describe "Serialization Tests" -tags "CI" { $outputs = SerializeAndDeserialize($inputObject); for($i=0;$i -lt $inputObject.Length;$i++) { - $outputs[$i] | Should be $inputObject[$i] + $outputs[$i] | Should -Be $inputObject[$i] } } } It 'Test Enum serialize and deserialize work as expected.' { $inputObject = [MyColorFlag]::RED - SerializeAndDeserialize($inputObject).ToString() | Should be $inputObject.ToString() + SerializeAndDeserialize($inputObject).ToString() | Should -Be $inputObject.ToString() } It 'Test SecureString serialize and deserialize work as expected.' { #[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Demo/doc/test secret.")] $inputObject = Convertto-Securestring -String "PowerShellRocks!" -AsPlainText -Force - SerializeAndDeserialize($inputObject).Length | Should be $inputObject.Length + SerializeAndDeserialize($inputObject).Length | Should -Be $inputObject.Length } @@ -96,7 +96,7 @@ Describe "Serialization Tests" -tags "CI" { $versionObject | Add-Member -MemberType NoteProperty -Name TestNote -Value "TestNote" $versionObject | Add-Member -MemberType ScriptProperty -Name TestScriptProperty -Value { ($this.TestNote) } - SerializeAndDeserialize($versionObject).TestScriptProperty | Should be $versionObject.TestScriptProperty + SerializeAndDeserialize($versionObject).TestScriptProperty | Should -Be $versionObject.TestScriptProperty } } diff --git a/test/powershell/engine/Api/TypeInference.Tests.ps1 b/test/powershell/engine/Api/TypeInference.Tests.ps1 index 44e5694d379..2d2ce7128d6 100644 --- a/test/powershell/engine/Api/TypeInference.Tests.ps1 +++ b/test/powershell/engine/Api/TypeInference.Tests.ps1 @@ -38,52 +38,52 @@ Describe "Type inference Tests" -tags "CI" { It "Infers type from integer" { $res = [AstTypeInference]::InferTypeOf( { 1 }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It "Infers type from string literal" { $res = [AstTypeInference]::InferTypeOf( { "Text" }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.String' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.String' } It "Infers type from type expression" { $res = [AstTypeInference]::InferTypeOf( { [int] }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Type' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Type' } It "Infers type from hashtable" { $res = [AstTypeInference]::InferTypeOf( { @{} }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Collections.Hashtable' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Collections.Hashtable' } It "Infers type from array expression" { $res = [AstTypeInference]::InferTypeOf( { @() }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.object[]' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.object[]' } It "Infers type from Array literal" { $res = [AstTypeInference]::InferTypeOf( { , 1 }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.object[]' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.object[]' } It "Infers type from array IndexExpresssion" { $res = [AstTypeInference]::InferTypeOf( { (1, 2, 3)[0] }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.object' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.object' } It "Infers type from generic container IndexExpression" { $res = [AstTypeInference]::InferTypeOf( { [System.Collections.Generic.List[int]]::new()[0] }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It 'Infers type of Index expression on Dictionary' { @@ -92,32 +92,32 @@ Describe "Type inference Tests" -tags "CI" { }.ast.EndBlock.Statements[0].PipelineElements[0].Expression $res = [AstTypeInference]::InferTypeOf( $ast ) - $res.Count | Should be 1 - $res.Name | Should be System.DateTime + $res.Count | Should -Be 1 + $res.Name | Should -Be System.DateTime } It "Infers type from ScriptblockExpresssion" { $res = [AstTypeInference]::InferTypeOf( { {} }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Management.Automation.Scriptblock' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Management.Automation.Scriptblock' } It "Infers type from paren expression" { $res = [AstTypeInference]::InferTypeOf( { (1) }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It "Infers type from expandable string expression" { $res = [AstTypeInference]::InferTypeOf( { "$(1)" }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.String' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.String' } It "Infers type from cast expression" { $res = [AstTypeInference]::InferTypeOf( { [int] '1'}.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It "Infers type from using namespace" { @@ -125,29 +125,29 @@ Describe "Type inference Tests" -tags "CI" { $tokens = $null $ast = [Language.Parser]::ParseInput("using namespace System", [ref] $tokens, [ref] $errors) $res = [AstTypeInference]::InferTypeOf( $ast.Find( {param($a) $a -is [System.Management.Automation.Language.UsingStatementAst] }, $true)) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It "Infers type from unary expression" { $res = [AstTypeInference]::InferTypeOf( { !$true }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Boolean' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Boolean' } It "Infers type from param block" { $res = [AstTypeInference]::InferTypeOf( { param() }.Ast) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It "Infers type from using statement" { $res = [AstTypeInference]::InferTypeOf( { $pid = 1; $using:pid }.Ast.EndBlock.Statements[1].PipelineElements[0].Expression) - $res.Count | Should Be 1 - $res.Name | Should Be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It "Infers type from param block" { $res = [AstTypeInference]::InferTypeOf( { param([int] $i)}.Ast.ParamBlock) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It "Infers type no type from Attribute" { @@ -155,7 +155,7 @@ Describe "Type inference Tests" -tags "CI" { [OutputType([int])] param( )}.Ast.ParamBlock.Attributes[0]) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It "Infers type no type from named Attribute argument" { @@ -163,23 +163,23 @@ Describe "Type inference Tests" -tags "CI" { [OutputType(Type = [int])] param( )}.Ast.ParamBlock.Attributes[0].NamedArguments[0]) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It "Infers type parameter types" { $res = [AstTypeInference]::InferTypeOf( { param([int] $i, [string] $s) }.Ast.ParamBlock.Parameters[0]) - $res.Count | Should Be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It "Infers type parameter from PSTypeNameAttribute type" -Skip:(!$IsWindows) { $res = [AstTypeInference]::InferTypeOf( { param([int] $i, [PSTypeName('System.Management.ManagementObject#root\cimv2\Win32_Process')] $s) }.Ast.ParamBlock.Parameters[1]) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Management.ManagementObject#root\cimv2\Win32_Process' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Management.ManagementObject#root\cimv2\Win32_Process' } It "Infers type from DATA statement" { @@ -188,14 +188,14 @@ Describe "Type inference Tests" -tags "CI" { "text" } }.Ast.EndBlock) - $res.Count | Should Be 1 - $res.Name | Should be 'System.String' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.String' } It "Infers type from named block" { $res = [AstTypeInference]::InferTypeOf( { begin {1}}.Ast.BeginBlock) - $res.Count | Should Be 1 - $res.Name | Should Be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It "Infers type from function definition" { @@ -204,7 +204,7 @@ Describe "Type inference Tests" -tags "CI" { return 1 } }.Ast.EndBlock) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It "Infers type from convert expression" { @@ -212,8 +212,8 @@ Describe "Type inference Tests" -tags "CI" { $tokens = $null $ast = [Language.Parser]::ParseInput('[int] "4"', [ref] $tokens, [ref] $errors) $res = [AstTypeInference]::InferTypeOf( $ast.EndBlock.Statements[0]) - $res.Count | Should Be 1 - $res.Name | Should Be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It "Infers type from type constraint" { @@ -221,110 +221,110 @@ Describe "Type inference Tests" -tags "CI" { $tokens = $null $ast = [Language.Parser]::ParseInput('[int] $i', [ref] $tokens, [ref] $errors) $res = [AstTypeInference]::InferTypeOf( $ast.EndBlock.Statements[0].PipelineElements[0].Expression.Attribute) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It "Infers type from instance member property" { $res = [AstTypeInference]::InferTypeOf( { 'Text'.Length }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It "Infers type from static member property" { $res = [AstTypeInference]::InferTypeOf( { [DateTime]::Now }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.DateTime' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.DateTime' } It "Infers type from instance member method" { $res = [AstTypeInference]::InferTypeOf( { [int[]].GetElementType() }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Type' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Type' } It "Infers type from integer * stringliteral" { $res = [AstTypeInference]::InferTypeOf( { 5 * "5" }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It "Infers type from string literal" { $res = [AstTypeInference]::InferTypeOf( { "Text" }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.String' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.String' } It "Infers type from stringliteral * integer" { $res = [AstTypeInference]::InferTypeOf( { "5" * 2 }.Ast) - $res.Count | Should Be 1 - $res.Name | Should be 'System.String' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.String' } It "Infers type from where-object of integer" { $res = [AstTypeInference]::InferTypeOf( { [int[]] $i = 1..20; $i | Where-Object {$_ -gt 10} }.Ast) foreach ($r in $res) { - $r.Name -in 'System.Int32', 'System.Int32[]' | Should be $true + $r.Name -In 'System.Int32', 'System.Int32[]' | Should -Be $true } } It "Infers type from foreach-object of integer" { $res = [AstTypeInference]::InferTypeOf( { [int[]] $i = 1..20; $i | ForEach-Object {$_ * 10} }.Ast) - $res.Count | Should Be 2 + $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -in 'System.Int32', 'System.Int32[]' | Should be $true + $r.Name -In 'System.Int32', 'System.Int32[]' | Should -Be $true } } It "Infers type from generic new" { $res = [AstTypeInference]::InferTypeOf( { [System.Collections.Generic.List[int]]::new() }.Ast) - $res.Count | Should Be 1 - $res.Name | Should Match 'System.Collections.Generic.List`1\[\[System.Int32.*' + $res.Count | Should -Be 1 + $res.Name | Should -Match 'System.Collections.Generic.List`1\[\[System.Int32.*' } It "Infers type from cim command" -Skip:(!$IsWindows) { $res = [AstTypeInference]::InferTypeOf( { Get-CimInstance -Namespace root/CIMV2 -ClassName Win32_Bios }.Ast) - $res.Count | Should Be 2 + $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -in 'Microsoft.Management.Infrastructure.CimInstance#root/CIMV2/Win32_Bios', - 'Microsoft.Management.Infrastructure.CimInstance' | Should be $true + $r.Name -In 'Microsoft.Management.Infrastructure.CimInstance#root/CIMV2/Win32_Bios', + 'Microsoft.Management.Infrastructure.CimInstance' | Should -Be $true } } It "Infers type from foreach-object with begin/end" { $res = [AstTypeInference]::InferTypeOf( { [int[]] $i = 1..20; $i | ForEach-Object -Begin {"Hi"} {$_ * 10} -End {[int]} }.Ast) - $res.Count | Should Be 4 + $res.Count | Should -Be 4 foreach ($r in $res) { - $r.Name -in 'System.Int32', 'System.Int32[]', 'System.String', 'System.Type' | Should be $true + $r.Name -In 'System.Int32', 'System.Int32[]', 'System.String', 'System.Type' | Should -Be $true } } It "Infers type from foreach-object with membername" { $res = [AstTypeInference]::InferTypeOf( { Get-ChildItem | ForEach-Object -MemberName Directory }.Ast) - $res.Count | Should Be 1 - $res.Name | Should Be "System.IO.DirectoryInfo" + $res.Count | Should -Be 1 + $res.Name | Should -Be "System.IO.DirectoryInfo" } It 'Infers typeof Foreach-Object -Member when Member is Property' { $ast = {Get-Process | Foreach-Object -Member FileVersion}.Ast $typeNames = [AstTypeInference]::InferTypeof($ast, [TypeInferenceRuntimePermissions]::AllowSafeEval) - $typeNames.Count | Should be 1 - $typeNames[0] | Should be 'System.String' + $typeNames.Count | Should -Be 1 + $typeNames[0] | Should -Be 'System.String' } It 'Infers typeof Foreach-Object -Member when member is ScriptProperty' { $ast = {Get-Process | Foreach-Object -Member Description}.Ast $typeNames = [AstTypeInference]::InferTypeof($ast, [TypeInferenceRuntimePermissions]::AllowSafeEval) - $typeNames.Count | Should be 1 - $typeNames[0] | Should be 'System.String' + $typeNames.Count | Should -Be 1 + $typeNames[0] | Should -Be 'System.String' } It 'Infers typeof Foreach-Object -Member when Member is Alias' { $ast = {Get-Process | Foreach-Object -Member Handles}.Ast $typeNames = [AstTypeInference]::InferTypeof($ast, [TypeInferenceRuntimePermissions]::AllowSafeEval) - $typeNames.Count | Should be 1 - $typeNames[0] | Should be 'System.Int32' + $typeNames.Count | Should -Be 1 + $typeNames[0] | Should -Be 'System.Int32' } It 'Infers typeof Foreach-Object -Member when using dependent scriptproperties' { @@ -343,8 +343,8 @@ Describe "Type inference Tests" -tags "CI" { try { $ast = {[InferScriptPropLevel2]::new() | Foreach-Object -MemberName XVal | ForEach-Object -MemberName TheValue}.Ast $typeNames = [AstTypeInference]::InferTypeof($ast, [TypeInferenceRuntimePermissions]::AllowSafeEval) - $typeNames.Count | Should be 1 - $typeNames[0] | Should be 'System.String' + $typeNames.Count | Should -Be 1 + $typeNames[0] | Should -Be 'System.String' } finally { Remove-TypeData -TypeName InferScriptPropLevel1 @@ -357,7 +357,7 @@ Describe "Type inference Tests" -tags "CI" { $gpsOutput = [Microsoft.PowerShell.Commands.GetProcessCommand].GetCustomAttributes([System.Management.Automation.OutputTypeAttribute], $false).Type $names = $gpsOutput.Name foreach ($r in $res) { - $r.Name -in $names | Should Be $true + $r.Name -In $names | Should -Be $true } } @@ -365,7 +365,7 @@ Describe "Type inference Tests" -tags "CI" { function Hide-GetProcess { Get-Process } $p = Hide-GetProcess $res = [AstTypeInference]::InferTypeOf( { $p }.Ast, [TypeInferenceRuntimePermissions]::AllowSafeEval) - $res.Name | Should Be 'System.Diagnostics.Process' + $res.Name | Should -Be 'System.Diagnostics.Process' } It "Infers type from variable with type in scope" { @@ -374,7 +374,7 @@ Describe "Type inference Tests" -tags "CI" { $p = 1 $p }.Ast) - $res.Name | Should Be 'System.Int32' + $res.Name | Should -Be 'System.Int32' } It "Infers type from block statement" { @@ -383,7 +383,7 @@ Describe "Type inference Tests" -tags "CI" { $ast = [Language.Parser]::ParseInput("parallel {1}", [ref] $tokens, [ref] $errors) $res = [AstTypeInference]::InferTypeOf( $ast.EndBlock.Statements[0]) - $res.Name | Should Be 'System.Int32' + $res.Name | Should -Be 'System.Int32' } It 'Infers type from attributed expession' { @@ -392,8 +392,8 @@ Describe "Type inference Tests" -tags "CI" { [int]$i = 1 }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type from if statement' { @@ -402,9 +402,9 @@ Describe "Type inference Tests" -tags "CI" { else { return 'Text'} }.Ast) - $res.Count | Should be 2 + $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -in 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Int32', 'System.String' | Should -Be $true } } @@ -417,9 +417,9 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Type', 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true } } @@ -432,9 +432,9 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Type', 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true } } @@ -447,9 +447,9 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Type', 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true } } @@ -462,9 +462,9 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Type', 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true } } @@ -477,9 +477,9 @@ Describe "Type inference Tests" -tags "CI" { }while ($true) }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Type', 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true } } @@ -492,9 +492,9 @@ Describe "Type inference Tests" -tags "CI" { } until ($true) }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Type', 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true } } @@ -505,9 +505,9 @@ Describe "Type inference Tests" -tags "CI" { end {[int]} }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Type', 'System.Int32', 'System.String' | Should be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true } } @@ -516,8 +516,8 @@ Describe "Type inference Tests" -tags "CI" { $(1) }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type from Throw statement' { @@ -525,7 +525,7 @@ Describe "Type inference Tests" -tags "CI" { throw 'Foo' }.Ast) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type from Return statement' { @@ -533,8 +533,8 @@ Describe "Type inference Tests" -tags "CI" { return 1 }.Ast) - $res.Count | Should be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It 'Infers type from New-Object statement' { @@ -542,8 +542,8 @@ Describe "Type inference Tests" -tags "CI" { New-Object -TypeName 'System.Diagnostics.Stopwatch' }.Ast) - $res.Count | Should be 1 - $res.Name | Should be 'System.Diagnostics.Stopwatch' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Diagnostics.Stopwatch' } It 'Infers type from Continue statement' { @@ -551,7 +551,7 @@ Describe "Type inference Tests" -tags "CI" { continue }.Ast) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type from Break statement' { @@ -559,7 +559,7 @@ Describe "Type inference Tests" -tags "CI" { break }.Ast) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type from Merging redirection' { @@ -567,7 +567,7 @@ Describe "Type inference Tests" -tags "CI" { $tokens = $null $ast = [Language.Parser]::ParseInput("p4 resolve ... 2>&1", [ref] $tokens, [ref] $errors) $res = [AstTypeInference]::InferTypeOf( $ast.EndBlock.Statements[0].PipelineElements[0].Redirections[0] ) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type from File redirection' { @@ -575,7 +575,7 @@ Describe "Type inference Tests" -tags "CI" { $tokens = $null $ast = [Language.Parser]::ParseInput("p4 resolve ... > foo.txt", [ref] $tokens, [ref] $errors) $res = [AstTypeInference]::InferTypeOf( $ast.EndBlock.Statements[0].PipelineElements[0].Redirections[0] ) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type of alias property' { @@ -587,8 +587,8 @@ Describe "Type inference Tests" -tags "CI" { [x]::new().AliasLength }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of code property' { @@ -602,8 +602,8 @@ Describe "Type inference Tests" -tags "CI" { [Y]::new().CodeProp }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of script property' { @@ -613,8 +613,8 @@ Describe "Type inference Tests" -tags "CI" { [Y]::new().ScriptProp }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of script property with outputtype' { @@ -624,8 +624,8 @@ Describe "Type inference Tests" -tags "CI" { [Y]::new().ScriptProp }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of script method with outputtype' { @@ -635,8 +635,8 @@ Describe "Type inference Tests" -tags "CI" { [Y]::new().MyScriptMethod }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of note property' { @@ -647,8 +647,8 @@ Describe "Type inference Tests" -tags "CI" { }.A }.Ast) - $res.Count | Should be 1 - $res.Name | Should be 'System.Management.Automation.PSObject' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Management.Automation.PSObject' } It 'Infers type of try catch finally' { @@ -665,9 +665,9 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast) - $res.Count | Should be 3 + $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -in 'System.Int32', 'System.String', 'System.Type' | Should be $true + $r.Name -In 'System.Int32', 'System.String', 'System.Type' | Should -Be $true } } @@ -677,15 +677,15 @@ Describe "Type inference Tests" -tags "CI" { "text" } }.Ast.EndBlock.Traps[0]) - $res.Count | Should Be 1 - $res.Name | Should be 'System.String' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.String' } It "Infers type from exit statement" { $res = [AstTypeInference]::InferTypeOf( { exit }.Ast.EndBlock) - $res.Count | Should Be 0 + $res.Count | Should -Be 0 } It 'Infers type of Where/Sort/Foreach pipeline' { @@ -693,7 +693,7 @@ Describe "Type inference Tests" -tags "CI" { [int[]](1..10) | Sort-Object -Descending | Where-Object {$_ -gt 3} | ForEach-Object {$_.ToString()} }.Ast) - $res.Name | Should be System.String + $res.Name | Should -Be System.String } It 'Infers type of Method accessed as Property' { @@ -701,8 +701,8 @@ Describe "Type inference Tests" -tags "CI" { ''.ToString }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Management.Automation.PSMethod + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Management.Automation.PSMethod } It 'Infers int from List[int] with foreach' { @@ -711,8 +711,8 @@ Describe "Type inference Tests" -tags "CI" { $l | ForEach-Object {$_} }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.String + $res.Count | Should -Be 1 + $res.Name | Should -Be System.String } It 'Infers class type' { @@ -725,7 +725,7 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } Context "TestDrivePath" { @@ -739,14 +739,14 @@ Describe "Type inference Tests" -tags "CI" { $cmdParam = $ast.EndBlock.Statements[0].Pipelineelements[0].CommandElements[1] $res = [AstTypeInference]::InferTypeOf( $cmdParam ) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type of command parameter - second form' { $ast = [Language.Parser]::ParseInput("Get-ChildItem -LiteralPath $p/foo.txt", [ref] $tokens, [ref] $errors) $cmdParam = $ast.EndBlock.Statements[0].Pipelineelements[0].CommandElements[1] $res = [AstTypeInference]::InferTypeOf( $cmdParam ) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type of common commands with Path parameter' { @@ -754,9 +754,9 @@ Describe "Type inference Tests" -tags "CI" { $cmdAst = $ast.EndBlock.Statements[0].Pipelineelements[0] $res = [AstTypeInference]::InferTypeOf( $cmdAst ) - $res.Count | Should be 2 + $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -in 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should be $true + $r.Name -In 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should -Be $true } } @@ -765,9 +765,9 @@ Describe "Type inference Tests" -tags "CI" { $cmdAst = $ast.EndBlock.Statements[0].Pipelineelements[0] $res = [AstTypeInference]::InferTypeOf( $cmdAst ) - $res.Count | Should be 2 + $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -in 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should be $true + $r.Name -In 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should -Be $true } } } @@ -776,32 +776,32 @@ Describe "Type inference Tests" -tags "CI" { $variableAst = {1..10 | Format-table @{n = 'x'; ex = {$_}}}.ast.Find( {param($a) $a -is [System.Management.Automation.Language.VariableExpressionAst]}, $true) $res = [AstTypeInference]::InferTypeOf( $variableAst) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of variable $_ in hashtable from Array' { $variableAst = { [int[]]::new(10) | Format-table @{n = 'x'; ex = {$_}}}.ast.Find( {param($a) $a -is [System.Management.Automation.Language.VariableExpressionAst]}, $true) $res = [AstTypeInference]::InferTypeOf( $variableAst) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of variable $_ in hashtable from generic IEnumerable ' { $variableAst = { [System.Collections.Generic.List[int]]::new() | Format-table @{n = 'x'; ex = {$_}}}.ast.Find( {param($a) $a -is [System.Management.Automation.Language.VariableExpressionAst]}, $true) $res = [AstTypeInference]::InferTypeOf( $variableAst) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of variable $_ command parameter' { $variableAst = { 1..10 | Group-Object {$_.Length}}.ast.Find( {param($a) $a -is [System.Management.Automation.Language.VariableExpressionAst]}, $true) $res = [AstTypeInference]::InferTypeOf( $variableAst) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of function member' { @@ -811,7 +811,7 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast.Find( {param($ast) $ast -is [System.Management.Automation.Language.FunctionMemberAst]}, $true)) - $res.Count | Should be 0 + $res.Count | Should -Be 0 } It 'Infers type of MemberExpression on class property' { @@ -823,8 +823,8 @@ Describe "Type inference Tests" -tags "CI" { $x.Date }.Ast.Find( {param($ast) $ast -is [System.Management.Automation.Language.MemberExpressionAst] -and $ast.Member.Value -eq 'Date'}, $true)) - $res.Count | Should be 1 - $res.Name | Should Be System.DateTime + $res.Count | Should -Be 1 + $res.Name | Should -Be System.DateTime } It 'Infers type of MemberExpression on class Method' { @@ -836,8 +836,8 @@ Describe "Type inference Tests" -tags "CI" { $x.GetDate() }.Ast.Find( {param($ast) $ast -is [System.Management.Automation.Language.MemberExpressionAst] -and $ast.Member.Value -eq 'GetDate'}, $true)) - $res.Count | Should be 1 - $res.Name | Should Be System.DateTime + $res.Count | Should -Be 1 + $res.Name | Should -Be System.DateTime } It 'Infers type of note property with safe eval' -Skip { @@ -847,8 +847,8 @@ Describe "Type inference Tests" -tags "CI" { }.A }.Ast) - $res.Count | Should be 1 - $res.Name | Should be 'System.String' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.String' } It 'Infers type of invoke operator scriptblock' -Skip { @@ -856,8 +856,8 @@ Describe "Type inference Tests" -tags "CI" { & {1} }.Ast) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of script property with safe eval' -Skip { @@ -867,8 +867,8 @@ Describe "Type inference Tests" -tags "CI" { [Y]::new().SafeEvalScriptProp }.Ast, [TypeInferenceRuntimePermissions]::AllowSafeEval) - $res.Count | Should be 1 - $res.Name | Should be System.Int32 + $res.Count | Should -Be 1 + $res.Name | Should -Be System.Int32 } It 'Infers type of base ctor' -Skip { @@ -882,7 +882,7 @@ Describe "Type inference Tests" -tags "CI" { } }.Ast.Find( {param($ast) $ast -is [System.Management.Automation.Language.BaseCtorInvokeMemberExpressionAst]}, $true)) - $res.Count | Should be BaseType + $res.Count | Should -Be BaseType } } @@ -890,15 +890,15 @@ Describe "AstTypeInference tests" -Tags CI { It "Infers type from integer with passed in powershell instance" { $powerShell = [PowerShell]::Create([RunspaceMode]::CurrentRunspace) $res = [AstTypeInference]::InferTypeOf( { 1 }.Ast, $powerShell) - $res.Count | Should Be 1 - $res.Name | Should be 'System.Int32' + $res.Count | Should -Be 1 + $res.Name | Should -Be 'System.Int32' } It "Infers type from integer with passed in powershell instance and typeinferencespermissions" { $powerShell = [PowerShell]::Create([RunspaceMode]::CurrentRunspace) $v = 1 $res = [AstTypeInference]::InferTypeOf( { $v }.Ast, $powerShell, [TypeInferenceRuntimePermissions]::AllowSafeEval) - $res.Name | Should be 'System.Int32' + $res.Name | Should -Be 'System.Int32' } } diff --git a/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 b/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 index de542d01ca7..69c419e89aa 100644 --- a/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 +++ b/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 @@ -53,18 +53,18 @@ Describe "Assembly.LoadFrom Validation Test" -Tags "CI" { It "Assembly.LoadFrom should automatically load the implicit referenced assembly from the same folder" { ## Both types should not be available before loading the test assemblies - { [Assembly.Foo.Consumer] } | Should Throw - { [Assembly.Bar.Provider] } | Should Throw + { [Assembly.Foo.Consumer] } | Should -Throw + { [Assembly.Bar.Provider] } | Should -Throw ## The type 'Assembly.Foo.Consumer' should be available after loading 'Consumer.dll' [System.Reflection.Assembly]::LoadFrom($ConsumerAssembly) > $null - [Assembly.Foo.Consumer].FullName | Should Be "Assembly.Foo.Consumer" + [Assembly.Foo.Consumer].FullName | Should -Be "Assembly.Foo.Consumer" ## The type 'Assembly.Bar.Provider' should still not be available - { [Assembly.Bar.Provider] } | Should Throw + { [Assembly.Bar.Provider] } | Should -Throw ## Calling '[Assembly.Foo.Consumer]::GetName()' will trigger implicit loading of 'Provider.dll' and the call should work - [Assembly.Foo.Consumer]::GetName() | Should Be "Assembly.Bar.Provider" + [Assembly.Foo.Consumer]::GetName() | Should -Be "Assembly.Bar.Provider" ## Now the type 'Assembly.Bar.Provider' should be available - [Assembly.Bar.Provider].FullName | Should Be "Assembly.Bar.Provider" + [Assembly.Bar.Provider].FullName | Should -Be "Assembly.Bar.Provider" } } diff --git a/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 b/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 index 0840bd451a8..86f754be0f2 100644 --- a/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 +++ b/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 @@ -24,7 +24,7 @@ Describe "Command Discovery tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | Should Be 'CommandNotFoundException' + $_.FullyQualifiedErrorId | Should -Be 'CommandNotFoundException' } } @@ -37,7 +37,7 @@ Describe "Command Discovery tests" -Tags "CI" { New-Item -Path "$TestDrive\\TestFunctionA\TestFunctionA.psm1" -Value "function TestFunctionA {}" | Out-Null $env:PSModulePath = "$TestDrive" + [System.IO.Path]::PathSeparator + "$TestDrive" - (Get-command 'TestFunctionA').count | Should Be 1 + (Get-command 'TestFunctionA').count | Should -Be 1 } finally { @@ -50,10 +50,10 @@ Describe "Command Discovery tests" -Tags "CI" { Set-Alias 'AliasCommandDiscoveryTest' Get-ChildItem $commands = (Get-Command 'AliasCommandDiscoveryTest') - $commands.Count | Should Be 1 + $commands.Count | Should -Be 1 $aliasResult = $commands -as [System.Management.Automation.AliasInfo] - $aliasResult | Should BeOfType [System.Management.Automation.AliasInfo] - $aliasResult.Name | Should Be 'AliasCommandDiscoveryTest' + $aliasResult | Should -BeOfType [System.Management.Automation.AliasInfo] + $aliasResult.Name | Should -Be 'AliasCommandDiscoveryTest' } It "Cyclic aliases - direct" { @@ -66,7 +66,7 @@ Describe "Command Discovery tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | Should Be 'CommandNotFoundException' + $_.FullyQualifiedErrorId | Should -Be 'CommandNotFoundException' } } @@ -81,27 +81,27 @@ Describe "Command Discovery tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | Should Be 'CommandNotFoundException' + $_.FullyQualifiedErrorId | Should -Be 'CommandNotFoundException' } } It "Get-Command should return only CmdletInfo, FunctionInfo, AliasInfo or FilterInfo" { $commands = Get-Command - $commands.Count | Should BeGreaterThan 0 + $commands.Count | Should -BeGreaterThan 0 foreach($command in $commands) { - $command.GetType().Name | Should BeIn @("AliasInfo","FunctionInfo","CmdletInfo","FilterInfo") + $command.GetType().Name | Should -BeIn @("AliasInfo","FunctionInfo","CmdletInfo","FilterInfo") } } It "Non-existent commands with wildcard should not write errors" { Get-Command "CommandDoesNotExist*" -ErrorVariable ev -ErrorAction SilentlyContinue - $ev | Should BeNullOrEmpty + $ev | Should -BeNullOrEmpty } It "Get- is prepended to commands" { - (& 'location').Path | Should Be (get-location).Path + (& 'location').Path | Should -Be (get-location).Path } } diff --git a/test/powershell/engine/Basic/Credential.Tests.ps1 b/test/powershell/engine/Basic/Credential.Tests.ps1 index cfbc37ab62d..2db15c05c8d 100644 --- a/test/powershell/engine/Basic/Credential.Tests.ps1 +++ b/test/powershell/engine/Basic/Credential.Tests.ps1 @@ -3,6 +3,6 @@ Describe "Credential tests" -Tags "CI" { It "Explicit cast for an empty credential returns null" { # We should explicitly check that the expression returns $null - [PSCredential]::Empty.GetNetworkCredential() | Should Be $null + [PSCredential]::Empty.GetNetworkCredential() | Should -Be $null } } diff --git a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 index 56db6f98cb2..f4435ad2db3 100644 --- a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 +++ b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 @@ -489,7 +489,7 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong aliases so we output them explicitly # if all aliases is Ok we output nothing $result | Write-Host - $result | Should Be $null + $result | Should -Be $null } It "All approved aliases have the correct 'AllScope' option" { @@ -501,7 +501,7 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong aliases so we output them explicitly # if all aliases is Ok we output nothing $result | Write-Host - $result | Should Be $null + $result | Should -Be $null } It "All approved aliases have the correct 'ReadOnly' option" { @@ -513,7 +513,7 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong aliases so we output them explicitly # if all aliases is Ok we output nothing $result | Write-Host - $result | Should Be $null + $result | Should -Be $null } It "All approved Cmdlets present (no new Cmdlets added, no Cmdlets removed)" { @@ -525,10 +525,10 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong Cmdlets so we output them explicitly # if all Cmdlets is Ok we output nothing $result | Write-Host - $result | Should Be $null + $result | Should -Be $null } It "Should have 'more' as a function" { - Test-Path Function:more | Should Be $true + Test-Path Function:more | Should -Be $true } } diff --git a/test/powershell/engine/Basic/Encoding.Tests.ps1 b/test/powershell/engine/Basic/Encoding.Tests.ps1 index 8ab4836441a..ee57fec455f 100644 --- a/test/powershell/engine/Basic/Encoding.Tests.ps1 +++ b/test/powershell/engine/Basic/Encoding.Tests.ps1 @@ -10,7 +10,7 @@ Describe "File encoding tests" -Tag CI { } It "Encoding parameter of command '' is type 'Encoding'" -Testcase $testCases { param ( $command ) - $command.Parameters['Encoding'].ParameterType.FullName | Should BeExactly "System.Text.Encoding" + $command.Parameters['Encoding'].ParameterType.FullName | Should -BeExactly "System.Text.Encoding" } } Context "File contents are UTF8 without BOM" { @@ -53,15 +53,15 @@ Describe "File encoding tests" -Tag CI { It "Export-CSV creates file with UTF-8 encoding without BOM" { [pscustomobject]@{ Key = $testStr } | Export-Csv $outputFile $bytes = Get-FileBytes $outputFile - $bytes[0,1,2] -join "-" | should not be ($utf8Preamble -join "-") - $bytes -join "-" | should match ($utf8bytes -join "-") + $bytes[0,1,2] -join "-" | should -Not -Be ($utf8Preamble -join "-") + $bytes -join "-" | should -Match ($utf8bytes -join "-") } It "Export-CliXml creates file with UTF-8 encoding without BOM" { [pscustomobject]@{ Key = $testStr } | Export-Clixml $outputFile $bytes = Get-FileBytes $outputFile - $bytes[0,1,2] -join "-" | should not be ($utf8Preamble -join "-") - $bytes -join "-" | should match ($utf8bytes -join "-") + $bytes[0,1,2] -join "-" | should -Not -Be ($utf8Preamble -join "-") + $bytes -join "-" | should -Match ($utf8bytes -join "-") } It "Appends correctly on non-Windows systems" -Skip:$IsWindows { @@ -69,7 +69,7 @@ Describe "File encoding tests" -Tag CI { ${testStr} >> $outputFile $bytes = Get-FileBytes $outputFile $Expected = $( $ExpectedWithNewline; $ExpectedWithNewline ) - $bytes -join "-" | should be ($Expected -join "-") + $bytes -join "-" | should -Be ($Expected -join "-") } } } diff --git a/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 b/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 index cbd4d10f92c..9465704b8be 100644 --- a/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 +++ b/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 @@ -68,7 +68,7 @@ try { It "Verify Queries to Missing File Return Default Value" { Remove-Item $userPropertiesFile -Force - Get-ExecutionPolicy -Scope CurrentUser | Should Be "Undefined" + Get-ExecutionPolicy -Scope CurrentUser | Should -Be "Undefined" # Verify the file was not created during the test try { @@ -76,7 +76,7 @@ try { throw "Properties file genererated during read operation" } catch { - $_.FullyQualifiedErrorId | Should Be "PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand" + $_.FullyQualifiedErrorId | Should -Be "PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand" } } @@ -84,20 +84,20 @@ try { # Create a valid file with no values Set-Content -Path $userPropertiesFile -Value "{}" - Get-ExecutionPolicy -Scope CurrentUser | Should Be "Undefined" + Get-ExecutionPolicy -Scope CurrentUser | Should -Be "Undefined" } It "Verify Writes Update Properties" { - Get-Content -Path $userPropertiesFile | Should Be '{"Microsoft.PowerShell:ExecutionPolicy":"RemoteSigned"}' + Get-Content -Path $userPropertiesFile | Should -Be '{"Microsoft.PowerShell:ExecutionPolicy":"RemoteSigned"}' Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass - Get-Content -Path $userPropertiesFile | Should Be '{"Microsoft.PowerShell:ExecutionPolicy":"Bypass"}' + Get-Content -Path $userPropertiesFile | Should -Be '{"Microsoft.PowerShell:ExecutionPolicy":"Bypass"}' } It "Verify Writes Create the File if Not Present" { Remove-Item $userPropertiesFile -Force - Test-Path $userPropertiesFile | Should Be $false + Test-Path $userPropertiesFile | Should -Be $false Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass - Get-Content -Path $userPropertiesFile | Should Be '{"Microsoft.PowerShell:ExecutionPolicy":"Bypass"}' + Get-Content -Path $userPropertiesFile | Should -Be '{"Microsoft.PowerShell:ExecutionPolicy":"Bypass"}' } } } diff --git a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 index 172ce829537..4cabf3a53b8 100644 --- a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 +++ b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 @@ -7,85 +7,85 @@ Describe "SemanticVersion api tests" -Tags 'CI' { Context "Constructing valid versions" { It "String argument constructor" { $v = [SemanticVersion]::new("1.2.3-Alpha-super.3+BLD.a1-xxx.03") - $v.Major | Should Be 1 - $v.Minor | Should Be 2 - $v.Patch | Should Be 3 - $v.PreReleaseLabel | Should Be "Alpha-super.3" - $v.BuildLabel | Should Be "BLD.a1-xxx.03" - $v.ToString() | Should Be "1.2.3-Alpha-super.3+BLD.a1-xxx.03" + $v.Major | Should -Be 1 + $v.Minor | Should -Be 2 + $v.Patch | Should -Be 3 + $v.PreReleaseLabel | Should -Be "Alpha-super.3" + $v.BuildLabel | Should -Be "BLD.a1-xxx.03" + $v.ToString() | Should -Be "1.2.3-Alpha-super.3+BLD.a1-xxx.03" $v = [SemanticVersion]::new("1.0.0") - $v.Major | Should Be 1 - $v.Minor | Should Be 0 - $v.Patch | Should Be 0 - $v.PreReleaseLabel | Should BeNullOrEmpty - $v.BuildLabel | Should BeNullOrEmpty - $v.ToString() | Should Be "1.0.0" + $v.Major | Should -Be 1 + $v.Minor | Should -Be 0 + $v.Patch | Should -Be 0 + $v.PreReleaseLabel | Should -BeNullOrEmpty + $v.BuildLabel | Should -BeNullOrEmpty + $v.ToString() | Should -Be "1.0.0" $v = [SemanticVersion]::new("3.0") - $v.Major | Should Be 3 - $v.Minor | Should Be 0 - $v.Patch | Should Be 0 - $v.PreReleaseLabel | Should BeNullOrEmpty - $v.BuildLabel | Should BeNullOrEmpty - $v.ToString() | Should Be "3.0.0" + $v.Major | Should -Be 3 + $v.Minor | Should -Be 0 + $v.Patch | Should -Be 0 + $v.PreReleaseLabel | Should -BeNullOrEmpty + $v.BuildLabel | Should -BeNullOrEmpty + $v.ToString() | Should -Be "3.0.0" $v = [SemanticVersion]::new("2") - $v.Major | Should Be 2 - $v.Minor | Should Be 0 - $v.Patch | Should Be 0 - $v.PreReleaseLabel | Should BeNullOrEmpty - $v.BuildLabel | Should BeNullOrEmpty - $v.ToString() | Should Be "2.0.0" + $v.Major | Should -Be 2 + $v.Minor | Should -Be 0 + $v.Patch | Should -Be 0 + $v.PreReleaseLabel | Should -BeNullOrEmpty + $v.BuildLabel | Should -BeNullOrEmpty + $v.ToString() | Should -Be "2.0.0" } # After the above test, we trust the properties and rely on ToString for validation It "Int args constructor" { $v = [SemanticVersion]::new(1, 0, 0) - $v.ToString() | Should Be "1.0.0" + $v.ToString() | Should -Be "1.0.0" $v = [SemanticVersion]::new(3, 2, 0, "beta.1") - $v.ToString() | Should Be "3.2.0-beta.1" + $v.ToString() | Should -Be "3.2.0-beta.1" $v = [SemanticVersion]::new(3, 2, 0, "beta.1+meta") - $v.ToString() | Should Be "3.2.0-beta.1+meta" + $v.ToString() | Should -Be "3.2.0-beta.1+meta" $v = [SemanticVersion]::new(3, 2, 0, "beta.1", "meta") - $v.ToString() | Should Be "3.2.0-beta.1+meta" + $v.ToString() | Should -Be "3.2.0-beta.1+meta" $v = [SemanticVersion]::new(3, 1) - $v.ToString() | Should Be "3.1.0" + $v.ToString() | Should -Be "3.1.0" $v = [SemanticVersion]::new(3) - $v.ToString() | Should Be "3.0.0" + $v.ToString() | Should -Be "3.0.0" } It "Version arg constructor" { $v = [SemanticVersion]::new([Version]::new(1, 2)) - $v.ToString() | Should Be '1.2.0' + $v.ToString() | Should -Be '1.2.0' $v = [SemanticVersion]::new([Version]::new(1, 2, 3)) - $v.ToString() | Should Be '1.2.3' + $v.ToString() | Should -Be '1.2.3' } It "Can covert to 'Version' type" { $v1 = [SemanticVersion]::new(3, 2, 1, "prerelease", "meta") $v2 = [Version]$v1 - $v2.GetType() | Should Be "Version" - $v2.PSobject.TypeNames[0] | Should Be "System.Version#IncludeLabel" - $v2.Major | Should Be 3 - $v2.Minor | Should Be 2 - $v2.Build | Should Be 1 - $v2.PSSemVerPreReleaseLabel | Should Be "prerelease" - $v2.PSSemVerBuildLabel | Should Be "meta" - $v2.ToString() | Should Be "3.2.1-prerelease+meta" + $v2.GetType() | Should -Be "Version" + $v2.PSobject.TypeNames[0] | Should -Be "System.Version#IncludeLabel" + $v2.Major | Should -Be 3 + $v2.Minor | Should -Be 2 + $v2.Build | Should -Be 1 + $v2.PSSemVerPreReleaseLabel | Should -Be "prerelease" + $v2.PSSemVerBuildLabel | Should -Be "meta" + $v2.ToString() | Should -Be "3.2.1-prerelease+meta" } It "Semantic version can round trip through version" { $v1 = [SemanticVersion]::new(3, 2, 1, "prerelease", "meta") $v2 = [SemanticVersion]::new([Version]$v1) - $v2.ToString() | Should Be "3.2.1-prerelease+meta" + $v2.ToString() | Should -Be "3.2.1-prerelease+meta" } } @@ -115,37 +115,37 @@ Describe "SemanticVersion api tests" -Tags 'CI' { } It "Build meta should be ignored" { - $v1_0_0_beta -eq $v1_0_0_betaBuild | Should Be $true - $v1_0_0_betaBuild -lt $v1_0_0_beta | Should Be $false - $v1_0_0_beta -lt $v1_0_0_betaBuild | Should Be $false + $v1_0_0_beta -eq $v1_0_0_betaBuild | Should -Be $true + $v1_0_0_betaBuild -lt $v1_0_0_beta | Should -Be $false + $v1_0_0_beta -lt $v1_0_0_betaBuild | Should -Be $false } It " less than " -TestCases $testCases { param($lhs, $rhs) - $lhs -lt $rhs | Should Be $true - $rhs -lt $lhs | Should Be $false + $lhs -lt $rhs | Should -Be $true + $rhs -lt $lhs | Should -Be $false } It " less than or equal " -TestCases $testCases { param($lhs, $rhs) - $lhs -le $rhs | Should Be $true - $rhs -le $lhs | Should Be $false - $lhs -le $lhs | Should Be $true - $rhs -le $rhs | Should Be $true + $lhs -le $rhs | Should -Be $true + $rhs -le $lhs | Should -Be $false + $lhs -le $lhs | Should -Be $true + $rhs -le $rhs | Should -Be $true } It " greater than " -TestCases $testCases { param($lhs, $rhs) - $lhs -gt $rhs | Should Be $false - $rhs -gt $lhs | Should Be $true + $lhs -gt $rhs | Should -Be $false + $rhs -gt $lhs | Should -Be $true } It " greater than or equal " -TestCases $testCases { param($lhs, $rhs) - $lhs -ge $rhs | Should Be $false - $rhs -ge $lhs | Should Be $true - $lhs -ge $lhs | Should Be $true - $rhs -ge $rhs | Should Be $true + $lhs -ge $rhs | Should -Be $false + $rhs -ge $lhs | Should -Be $true + $lhs -ge $lhs | Should -Be $true + $rhs -ge $rhs | Should -Be $true } It "Equality " -TestCases @( @@ -153,23 +153,23 @@ Describe "SemanticVersion api tests" -Tags 'CI' { @{ operand = $v1_0_0_alpha } ) { param($operand) - $operand -eq $operand | Should Be $true - $operand -ne $operand | Should Be $false - $null -eq $operand | Should Be $false - $operand -eq $null | Should Be $false - $null -ne $operand | Should Be $true - $operand -ne $null | Should Be $true + $operand -eq $operand | Should -Be $true + $operand -ne $operand | Should -Be $false + $null -eq $operand | Should -Be $false + $operand -eq $null | Should -Be $false + $null -ne $operand | Should -Be $true + $operand -ne $null | Should -Be $true } It "comparisons with null" { - $v1_0_0 -lt $null | Should Be $false - $null -lt $v1_0_0 | Should Be $true - $v1_0_0 -le $null | Should Be $false - $null -le $v1_0_0 | Should Be $true - $v1_0_0 -gt $null | Should Be $true - $null -gt $v1_0_0 | Should Be $false - $v1_0_0 -ge $null | Should Be $true - $null -ge $v1_0_0 | Should Be $false + $v1_0_0 -lt $null | Should -Be $false + $null -lt $v1_0_0 | Should -Be $true + $v1_0_0 -le $null | Should -Be $false + $null -le $v1_0_0 | Should -Be $true + $v1_0_0 -gt $null | Should -Be $true + $null -gt $v1_0_0 | Should -Be $false + $v1_0_0 -ge $null | Should -Be $true + $null -ge $v1_0_0 | Should -Be $false } } @@ -211,8 +211,8 @@ Describe "SemanticVersion api tests" -Tags 'CI' { { [SemanticVersion]::Parse($version) } | ShouldBeErrorId $errorId } $semVer = $null - [SemanticVersion]::TryParse($_, [ref]$semVer) | Should Be $expectedResult - $semVer | Should Be $null + [SemanticVersion]::TryParse($_, [ref]$semVer) | Should -Be $expectedResult + $semVer | Should -Be $null } It "Negative version arguments" { @@ -241,8 +241,8 @@ Describe "SemanticVersion api tests" -Tags 'CI' { $ser = [PSSerializer]::Serialize($semver) $des = [PSSerializer]::Deserialize($ser) - $des | Should BeOfType System.Management.Automation.SemanticVersion - $des.ToString() | Should Be $expectedResult + $des | Should -BeOfType System.Management.Automation.SemanticVersion + $des.ToString() | Should -Be $expectedResult } } } diff --git a/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 b/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 index 87755ed0a00..0c07483a2dd 100644 --- a/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 +++ b/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 @@ -43,12 +43,12 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { $ScriptBlock | ShouldBeErrorId $FullyQualifiedErrorId if ($InnerErrorId) { - $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should Be $InnerErrorId + $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should -Be $InnerErrorId } } It 'No Exception: valid argument count' { - { function foo { param([ValidateCount(2, 4)] [string[]] $bar) }; foo 1,2,3,4 } | Should Not Throw + { function foo { param([ValidateCount(2, 4)] [string[]] $bar) }; foo 1,2,3,4 } | Should -Not -Throw } } @@ -83,7 +83,7 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { $ScriptBlock | ShouldBeErrorId $FullyQualifiedErrorId if ($InnerErrorId) { - $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should Be $InnerErrorId + $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should -Be $InnerErrorId } } } @@ -119,13 +119,13 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { $ScriptBlock | ShouldBeErrorId $FullyQualifiedErrorId if ($InnerErrorId) { - $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should Be $InnerErrorId + $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should -Be $InnerErrorId } } It 'No Exception: value within range' -TestCases $validTestCases { param($ScriptBlock) - $ScriptBlock | Should Not Throw + $ScriptBlock | Should -Not -Throw } } @@ -253,13 +253,13 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { $ScriptBlock | ShouldBeErrorId $FullyQualifiedErrorId if ($InnerErrorId) { - $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should Be $InnerErrorId + $error[0].exception.innerexception.errorrecord.FullyQualifiedErrorId | Should -Be $InnerErrorId } } It 'No Exception: RangeType: - argument ""' -TestCases $validTestCases { param($ScriptBlock, $RangeType, $testValue) - $ScriptBlock | Should Not Throw + $ScriptBlock | Should -Not -Throw } } @@ -348,7 +348,7 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { It "Validate running time ''" -TestCases $testCases { param ($ScriptBlock) - (Measure-Command $ScriptBlock).Milliseconds | Should BeLessThan $UpperBoundTime + (Measure-Command $ScriptBlock).Milliseconds | Should -BeLessThan $UpperBoundTime } It "COM enumerable argument should work with 'ValidateNotNull' and 'ValidateNotNullOrEmpty'" -Skip:(!$IsWindows) { @@ -356,36 +356,36 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { $folder = $shell.Namespace("$TESTDRIVE") $items = $folder.Items() - NotNullFunc -Value $items -TestType "COM-Enumerable" | Should Be "file1" - NotNullOrEmptyFunc -Value $items -TestType "COM-Enumerable" | Should Be "file1" + NotNullFunc -Value $items -TestType "COM-Enumerable" | Should -Be "file1" + NotNullOrEmptyFunc -Value $items -TestType "COM-Enumerable" | Should -Be "file1" } It "Enumerator argument should work with 'ValidateNotNull' and 'ValidateNotNullOrEmpty'" { $data = @(1,2,3) - NotNullFunc -Value $data.GetEnumerator() -TestType "Enumerator" | Should Be "1,2,3" - NotNullOrEmptyFunc -Value $data.GetEnumerator() -TestType "Enumerator" | Should Be "1,2,3" + NotNullFunc -Value $data.GetEnumerator() -TestType "Enumerator" | Should -Be "1,2,3" + NotNullOrEmptyFunc -Value $data.GetEnumerator() -TestType "Enumerator" | Should -Be "1,2,3" } It "'ValidateNotNull' should throw on null element of a collection argument" { ## Should throw on null element - { NotNullFunc -Value @("string", $null, 2) } | Should Throw + { NotNullFunc -Value @("string", $null, 2) } | Should -Throw ## Should not throw on empty string element - { NotNullFunc -Value @("string", "", 2) } | Should Not Throw + { NotNullFunc -Value @("string", "", 2) } | Should -Not -Throw ## Should not throw on an empty collection - { NotNullFunc -Value @() } | Should Not Throw + { NotNullFunc -Value @() } | Should -Not -Throw } It "'ValidateNotNullOrEmpty' should throw on null element of a collection argument or empty collection/dictionary" { - { NotNullOrEmptyFunc -Value @("string", $null, 2) } | Should Throw - { NotNullOrEmptyFunc -Value @("string", "", 2) } | Should Throw - { NotNullOrEmptyFunc -Value @() } | Should Throw - { NotNullOrEmptyFunc -Value @{} } | Should Throw + { NotNullOrEmptyFunc -Value @("string", $null, 2) } | Should -Throw + { NotNullOrEmptyFunc -Value @("string", "", 2) } | Should -Throw + { NotNullOrEmptyFunc -Value @() } | Should -Throw + { NotNullOrEmptyFunc -Value @{} } | Should -Throw } It "Mandatory parameter should throw on empty collection" { - { MandatoryFunc -ByteArray ([byte[]]@()) } | Should Throw - { MandatoryFunc -ByteList ([System.Collections.Generic.List[byte]]@()) } | Should Throw - { MandatoryFunc -ByteList ([System.Collections.ObjectModel.Collection[byte]]@()) } | Should Throw + { MandatoryFunc -ByteArray ([byte[]]@()) } | Should -Throw + { MandatoryFunc -ByteList ([System.Collections.Generic.List[byte]]@()) } | Should -Throw + { MandatoryFunc -ByteList ([System.Collections.ObjectModel.Collection[byte]]@()) } | Should -Throw } } } diff --git a/test/powershell/engine/COM/COM.Basic.Tests.ps1 b/test/powershell/engine/COM/COM.Basic.Tests.ps1 index d6477f998c5..3d35f74f966 100644 --- a/test/powershell/engine/COM/COM.Basic.Tests.ps1 +++ b/test/powershell/engine/COM/COM.Basic.Tests.ps1 @@ -18,11 +18,11 @@ try { $items = $folder.Items() ## $items is a collection of all items belong to the folder, and it should be enumerated. - $items.Count | Should Be 3 - $items | Measure-Object | ForEach-Object Count | Should Be $items.Count + $items.Count | Should -Be 3 + $items | Measure-Object | ForEach-Object Count | Should -Be $items.Count $names = $items | ForEach-Object { $_.Name } - $names -join "," | Should Be "file1,file2,file3" + $names -join "," | Should -Be "file1,file2,file3" } It "Should enumerate IEnumVariant interface object without exception" { @@ -32,8 +32,8 @@ try { ## $enumVariant is an IEnumVariant interface of all items belong to the folder, and it should be enumerated. $enumVariant = $items._NewEnum() - $items.Count | Should Be 3 - $enumVariant | Measure-Object | ForEach-Object Count | Should Be $items.Count + $items.Count | Should -Be 3 + $enumVariant | Measure-Object | ForEach-Object Count | Should -Be $items.Count } It "Should enumerate drives" { @@ -41,12 +41,12 @@ try { $drives = $fileSystem.Drives ## $drives is a read-only collection of all available drives, and it should be enumerated. - $drives | Measure-Object | ForEach-Object Count | Should Be $drives.Count + $drives | Measure-Object | ForEach-Object Count | Should -Be $drives.Count ## $element should be the first drive from the enumeration. It shouldn't be the same as $drives, ## but it should be the same as '$drives.Item($element.DriveLetter)' $element = $drives | Select-Object -First 1 - [System.Object]::ReferenceEquals($element, $drives) | Should Be $false - $element | Should Be $drives.Item($element.DriveLetter) + [System.Object]::ReferenceEquals($element, $drives) | Should -Be $false + $element | Should -Be $drives.Item($element.DriveLetter) } } @@ -72,7 +72,7 @@ try { $entry2 = ($str, "Hello") foreach ($pair in ($entry1, $entry2, $entry2, $entry1, $entry1, $entry2)) { - $pair[0].Name | Should Be $pair[1] + $pair[0].Name | Should -Be $pair[1] } } @@ -83,7 +83,7 @@ try { foreach ($pair in ($entry1, $entry2)) { $pair[0].Name = $pair[1] - $pair[0].Name | Should Be $pair[1] + $pair[0].Name | Should -Be $pair[1] } } @@ -92,7 +92,7 @@ try { $shell | ForEach-Object { $_.Windows() } > $null ## '$str' is a PSObject that wraps a string, but with ScriptMethod 'Windows' - $str.Windows() | Should Be "Windows" + $str.Windows() | Should -Be "Windows" } } diff --git a/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 b/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 index 349139efd14..ebd1ec43c95 100644 --- a/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 +++ b/test/powershell/engine/Cdxml/Cdxml.Tests.ps1 @@ -102,39 +102,39 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { Context "Module level tests" { It "The CimTest module should have been loaded" @ItSkipOrPending { $result = Get-Module CimTest - $result.ModuleBase | should be ${script:ModuleDir} + $result.ModuleBase | should -Be ${script:ModuleDir} } It "The CimTest module should have the proper cmdlets" @ItSkipOrPending { $result = Get-Command -Module CimTest - $result.Count | Should Be 4 - ($result.Name | sort-object ) -join "," | Should Be "Get-CimTest,New-CimTest,Remove-CimTest,Set-CimTest" + $result.Count | Should -Be 4 + ($result.Name | sort-object ) -join "," | Should -Be "Get-CimTest,New-CimTest,Remove-CimTest,Set-CimTest" } } Context "Get-CimTest cmdlet" { It "The Get-CimTest cmdlet should return 4 objects" @ItSkipOrPending { $result = Get-CimTest - $result.Count | should be 4 - ($result.id |sort-object) -join "," | should be "1,2,3,4" + $result.Count | should -Be 4 + ($result.id |sort-object) -join "," | should -Be "1,2,3,4" } It "The Get-CimTest cmdlet should retrieve an object via id" @ItSkipOrPending { $result = Get-CimTest -id 1 - @($result).Count | should be 1 - $result.field1 | Should be "instance 1" + @($result).Count | should -Be 1 + $result.field1 | Should -Be "instance 1" } It "The Get-CimTest cmdlet should retrieve an object by piped id" @ItSkipOrPending { $result = 1,2,4 | foreach-object { [pscustomobject]@{ id = $_ } } | Get-CimTest - @($result).Count | should be 3 - ( $result.id | sort-object ) -join "," | Should be "1,2,4" + @($result).Count | should -Be 3 + ( $result.id | sort-object ) -join "," | Should -Be "1,2,4" } It "The Get-CimTest cmdlet should retrieve an object by datetime" @ItSkipOrPending { $result = Get-CimTest -DateTime ([datetime]::new(2008,01,01,0,0,0)) - @($result).Count | Should Be 1 - $result.field1 | Should Be "instance 1" + @($result).Count | Should -Be 1 + $result.field1 | Should -Be "instance 1" } It "The Get-CimTest cmdlet should return the proper error if the instance does not exist" @ItSkipOrPending { @@ -150,8 +150,8 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { # the time can be adjusted $null = Wait-Job -Job $job -timeout 10 $result = $job | Receive-Job - $result.Count | should be 4 - ( $result.id | sort-object ) -join "," | Should be "1,2,3,4" + $result.Count | should -Be 4 + ( $result.id | sort-object ) -join "," | Should -Be "1,2,3,4" } finally { if ( $job ) { @@ -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] } } @@ -180,15 +180,15 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { It "The Remote-CimTest cmdlet should remove objects by id" @ItSkipOrPending { Remove-CimTest -id 1 $result = Get-CimTest - $result.Count | should be 3 - ($result.id |sort-object) -join "," | should be "2,3,4" + $result.Count | should -Be 3 + ($result.id |sort-object) -join "," | should -Be "2,3,4" } It "The Remove-CimTest cmdlet should remove piped objects" @ItSkipOrPending { Get-CimTest -id 2 | Remove-CimTest $result = Get-CimTest - @($result).Count | should be 3 - ($result.id |sort-object) -join "," | should be "1,3,4" + @($result).Count | should -Be 3 + ($result.id |sort-object) -join "," | should -Be "1,3,4" } It "The Remove-CimTest cmdlet should work as a job" @ItSkipOrPending { @@ -200,8 +200,8 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { # the time can be adjusted $null = Wait-Job -Job $job -Timeout 10 $result = Get-CimTest - @($result).Count | should be 3 - ($result.id |sort-object) -join "," | should be "1,2,4" + @($result).Count | should -Be 3 + ($result.id |sort-object) -join "," | should -Be "1,2,4" } finally { if ( $job ) { @@ -220,8 +220,8 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { } New-CimTest @instanceArgs $result = Get-CimInstance -namespace root/default -class PSCore_Test1 | Where-Object {$_.id -eq "telephone"} - $result.field2 | should be 0 - $result.field1 | Should be $instanceArgs.field1 + $result.field2 | should -Be 0 + $result.field1 | Should -Be $instanceArgs.field1 } It "Should return the proper error if called with an improper value" @ItSkipOrPending { @@ -232,7 +232,7 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { } { New-CimTest @instanceArgs } | ShouldBeErrorId "ParameterArgumentTransformationError,New-CimTest" # just make sure that it wasn't added - Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should BeNullOrEmpty + Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should -BeNullOrEmpty } It "Should support -whatif" @ItSkipOrPending { @@ -243,7 +243,7 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { Whatif = $true } New-CimTest @instanceArgs - Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should BeNullOrEmpty + Get-CimTest -id $instanceArgs.Id -ea SilentlyContinue | Should -BeNullOrEmpty } } @@ -261,12 +261,12 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { } New-CimTest @instanceArgs $result = Get-CimTest -id $instanceArgs.id - $result.field2 | should be $instanceArgs.field2 - $result.field1 | Should be $instanceArgs.field1 + $result.field2 | should -Be $instanceArgs.field2 + $result.field1 | Should -Be $instanceArgs.field1 Set-CimTest @newValues $result = Get-CimTest -id $newValues.id - $result.field1 | Should be $newValues.field1 - $result.field2 | should be $newValues.field2 + $result.field1 | Should -Be $newValues.field1 + $result.field2 | should -Be $newValues.field2 } It "Should set properties on an instance via pipeline" @ItSkipOrPending { @@ -277,14 +277,14 @@ Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows { } New-CimTest @instanceArgs $result = Get-CimTest -id $instanceArgs.id - $result.field2 | should be $instanceArgs.field2 - $result.field1 | Should be $instanceArgs.field1 + $result.field2 | should -Be $instanceArgs.field2 + $result.field1 | Should -Be $instanceArgs.field1 $result.field1 = "yet another value" $result.field2 = 33 $result | Set-CimTest $result = Get-CimTest -id $instanceArgs.id - $result.field1 | Should be "yet another value" - $result.field2 | should be 33 + $result.field1 | Should -Be "yet another value" + $result.field2 | should -Be 33 } } diff --git a/test/powershell/engine/ETS/Adapter.Tests.ps1 b/test/powershell/engine/ETS/Adapter.Tests.ps1 index 5dc7794ef54..b7cc7c33535 100644 --- a/test/powershell/engine/ETS/Adapter.Tests.ps1 +++ b/test/powershell/engine/ETS/Adapter.Tests.ps1 @@ -29,59 +29,59 @@ Describe "Adapter Tests" -tags "CI" { It "Can get a Dotnet parameterized property" { $col = $pso.psobject.Properties.Match("*") $prop = $col.psobject.Members["Item"] - $prop | Should Not BeNullOrEmpty - $prop.IsGettable | Should Be $true - $prop.IsSettable | Should Be $false - $prop.TypeNameOfValue | Should Be "System.Management.Automation.PSPropertyInfo" - $prop.Invoke("ProcessName").Value | Should Be $processName + $prop | Should -Not -BeNullOrEmpty + $prop.IsGettable | Should -Be $true + $prop.IsSettable | Should -Be $false + $prop.TypeNameOfValue | Should -Be "System.Management.Automation.PSPropertyInfo" + $prop.Invoke("ProcessName").Value | Should -Be $processName } It "Can get a property" { - $pso.psobject.Properties["ProcessName"] | Should Not BeNullOrEmpty + $pso.psobject.Properties["ProcessName"] | Should -Not -BeNullOrEmpty } It "Can access all properties" { $props = $pso.psobject.Properties.Match("*") - $props | Should Not BeNullOrEmpty - $props["ProcessName"].Value | Should Be $processName + $props | Should -Not -BeNullOrEmpty + $props["ProcessName"].Value | Should -Be $processName } It "Can invoke a method" { $method = $pso.psobject.Methods["ToString"] - $method.Invoke() | Should Be ($pso.ToString()) + $method.Invoke() | Should -Be ($pso.ToString()) } It "Access a Method via MemberSet adapter" { $prop = $psmemberset.psobject.Members["TestCodeMethod"] - $prop.Invoke(2) | Should Be 1 + $prop.Invoke(2) | Should -Be 1 } It "Access misc properties via MemberSet adapter" { $prop = $psmemberset.psobject.Properties["NoteName"] - $prop | Should Not BeNullOrEmpty - $prop.IsGettable | Should Be $true - $prop.IsSettable | Should Be $true - $prop.TypeNameOfValue | Should Be "System.Int32" + $prop | Should -Not -BeNullOrEmpty + $prop.IsGettable | Should -Be $true + $prop.IsSettable | Should -Be $true + $prop.TypeNameOfValue | Should -Be "System.Int32" } It "Access all the properties via XmlAdapter" { $col = $doc.psobject.Properties.Match("*") - $col.Count | Should Not Be 0 + $col.Count | Should -Not -Be 0 $prop = $col["price"] - $prop | Should Not BeNullOrEmpty + $prop | Should -Not -BeNullOrEmpty } It "Access all the properties via XmlAdapter" { $prop = $doc.psobject.Properties["price"] - $prop.Value | Should Be "19.95" - $prop.IsGettable | Should Not BeNullOrEmpty - $prop.IsSettable | Should Not BeNullOrEmpty - $prop.TypeNameOfValue | Should Be "System.String" + $prop.Value | Should -Be "19.95" + $prop.IsGettable | Should -Not -BeNullOrEmpty + $prop.IsSettable | Should -Not -BeNullOrEmpty + $prop.TypeNameOfValue | Should -Be "System.String" } It "Call to string on a XmlNode object" { $val = $doc.ToString() - $val | Should Be "book" + $val | Should -Be "book" } It "Calls CodeMethod with void result" { @@ -106,11 +106,11 @@ Describe "Adapter Tests" -tags "CI" { Update-TypeData -Force -TypeName TestCodeMethodInvokationWithVoidReturn -MemberType CodeMethod -MemberName VoidMethod -Value ([TestCodeMethodInvokationWithVoidReturn]::GetMethodInfo('VoidMethodCM')) try { $o = [TestCodeMethodInvokationWithVoidReturn]::new() - $o.CallCounter | Should Be 0 + $o.CallCounter | Should -Be 0 $o.VoidMethod() - $o.CallCounter | Should Be 1 + $o.CallCounter | Should -Be 1 - $o.IntMethod() | Should Be 1 + $o.IntMethod() | Should -Be 1 } finally { Remove-TypeData TestCodeMethodInvokationWithVoidReturn @@ -120,41 +120,41 @@ Describe "Adapter Tests" -tags "CI" { It "Count and length property works for singletons" { # Return magic Count and Length property if it absent. $x = 5 - $x.Count | Should Be 1 - $x.Length | Should Be 1 + $x.Count | Should -Be 1 + $x.Length | Should -Be 1 - $null.Count | Should Be 0 - $null.Length | Should Be 0 + $null.Count | Should -Be 0 + $null.Length | Should -Be 0 - (10).Count | Should Be 1 - (10).Length | Should Be 1 + (10).Count | Should -Be 1 + (10).Length | Should -Be 1 - ("a").Count | Should Be 1 + ("a").Count | Should -Be 1 # The Length property exists in String type, so here we check that we don't break strings. - ("a").Length | Should Be 1 - ("aa").Length | Should Be 2 + ("a").Length | Should -Be 1 + ("aa").Length | Should -Be 2 - ([psobject] @{ foo = 'bar' }).Count | Should Be 1 - ([psobject] @{ foo = 'bar' }).Length | Should Be 1 + ([psobject] @{ foo = 'bar' }).Count | Should -Be 1 + ([psobject] @{ foo = 'bar' }).Length | Should -Be 1 - ([pscustomobject] @{ foo = 'bar' }).Count | Should Be 1 - ([pscustomobject] @{ foo = 'bar' }).Length | Should Be 1 + ([pscustomobject] @{ foo = 'bar' }).Count | Should -Be 1 + ([pscustomobject] @{ foo = 'bar' }).Length | Should -Be 1 # Return real Count and Length property if it present. - ([pscustomobject] @{ foo = 'bar'; count = 5 }).Count | Should Be 5 - ([pscustomobject] @{ foo = 'bar'; length = 5 }).Length | Should Be 5 + ([pscustomobject] @{ foo = 'bar'; count = 5 }).Count | Should -Be 5 + ([pscustomobject] @{ foo = 'bar'; length = 5 }).Length | Should -Be 5 } } Context "Null Magic Method Adapter Tests" { It "ForEach and Where works for Null" { $res = $null.ForEach({1}) - $res.Count | Should Be 0 - $res.GetType().Name | Should BeExactly "Collection``1" + $res.Count | Should -Be 0 + $res.GetType().Name | Should -BeExactly "Collection``1" $null.Where({$true}) - $res.Count | Should Be 0 - $res.GetType().Name | Should BeExactly "Collection``1" + $res.Count | Should -Be 0 + $res.GetType().Name | Should -BeExactly "Collection``1" } } @@ -164,20 +164,20 @@ Describe "Adapter Tests" -tags "CI" { It "ForEach magic method works for singletions" { $x = 5 - $x.ForEach({$_}) | Should Be 5 - (5).ForEach({$_}) | Should Be 5 - ("a").ForEach({$_}) | Should BeExactly "a" + $x.ForEach({$_}) | Should -Be 5 + (5).ForEach({$_}) | Should -Be 5 + ("a").ForEach({$_}) | Should -BeExactly "a" - ([pscustomobject]@{ foo = 'bar' }).ForEach({1}) | Should Be 1 + ([pscustomobject]@{ foo = 'bar' }).ForEach({1}) | Should -Be 1 $x = ([pscustomobject]@{ foo = 'bar' }).ForEach({$_}) - $x.Count | Should Be 1 - $x[0].foo | Should BeExactly "bar" + $x.Count | Should -Be 1 + $x[0].foo | Should -BeExactly "bar" $x = ([pscustomobject]@{ foo = 'bar' }).Foreach({$_ | Add-Member -NotePropertyName "foo2" -NotePropertyValue "bar2" -PassThru}) - $x.Count | Should Be 1 - $x[0].foo | Should BeExactly "bar" - $x[0].foo2 | Should BeExactly "bar2" + $x.Count | Should -Be 1 + $x[0].foo | Should -BeExactly "bar" + $x[0].foo2 | Should -BeExactly "bar2" # We call ForEach method defined in an object if it is present (not magic ForEach method). $x = [pscustomobject]@{ foo = 'bar' } @@ -185,7 +185,7 @@ Describe "Adapter Tests" -tags "CI" { param ( [int]$param1 ) $param1*2 } -PassThru -Force - $x.ForEach(5) | Should Be 10 + $x.ForEach(5) | Should -Be 10 } } @@ -195,29 +195,29 @@ Describe "Adapter Tests" -tags "CI" { It "Where magic method works for singletions" { $x = 5 - $x.Where({$true}) | Should Be 5 - (5).Where({$true}) | Should Be 5 - ("a").Where({$true}) | Should Be "a" + $x.Where({$true}) | Should -Be 5 + (5).Where({$true}) | Should -Be 5 + ("a").Where({$true}) | Should -Be "a" $x = ([pscustomobject] @{ foo = 'bar' }).Where({$true}) - $x.Count | Should Be 1 - $x[0].foo | Should BeExactly "bar" + $x.Count | Should -Be 1 + $x[0].foo | Should -BeExactly "bar" $x = ([pscustomobject] @{ foo = 'bar' }).Where({$true}, 0) - $x.Count | Should Be 1 - $x[0].foo | Should BeExactly "bar" + $x.Count | Should -Be 1 + $x[0].foo | Should -BeExactly "bar" $x = ([pscustomobject] @{ foo = 'bar' }).Where({$true}, "Default") - $x.Count | Should Be 1 - $x[0].foo | Should BeExactly "bar" + $x.Count | Should -Be 1 + $x[0].foo | Should -BeExactly "bar" $x = ([pscustomobject] @{ foo = 'bar' }).Where({$true}, "Default", 0) - $x.Count | Should Be 1 - $x[0].foo | Should BeExactly "bar" + $x.Count | Should -Be 1 + $x[0].foo | Should -BeExactly "bar" $x = ([pscustomobject] @{ foo = 'bar' }).Where({$true}, "Default", "0") - $x.Count | Should Be 1 - $x[0].foo | Should BeExactly "bar" + $x.Count | Should -Be 1 + $x[0].foo | Should -BeExactly "bar" # We call Where method defined in an object if it is present (not magic Where method). $x = [pscustomobject]@{ foo = 'bar' } @@ -225,7 +225,7 @@ Describe "Adapter Tests" -tags "CI" { param ( [int]$param1 ) $param1*2 } -PassThru -Force - $x.Where(5) | Should Be 10 + $x.Where(5) | Should -Be 10 } } } @@ -251,8 +251,8 @@ Describe "Adapter XML Tests" -tags "CI" { # rval will be implicitly converted to 'string' type param($rval) { - { $x.root.data = $rval } | Should Not Throw - $x.root.data | Should Be [System.Management.Automation.LanguagePrimitives]::ConvertTo($rval, [string]) + { $x.root.data = $rval } | Should -Not -Throw + $x.root.data | Should -Be [System.Management.Automation.LanguagePrimitives]::ConvertTo($rval, [string]) } } } @@ -280,19 +280,19 @@ Describe "DataRow and DataRowView Adapter tests" -tags "CI" { It "Should be able to access data columns" { $row = $dataTable.Rows[0] - $row.Id | Should Be 1 - $row.FirstName | Should Be "joseph" - $row.LastName | Should Be "smith" - $row.YearsInMS | Should Be 15 + $row.Id | Should -Be 1 + $row.FirstName | Should -Be "joseph" + $row.LastName | Should -Be "smith" + $row.YearsInMS | Should -Be 15 } It "DataTable should be enumerable in PowerShell" { ## Get the third entry in the data table $row = $dataTable | Select-Object -Skip 2 -First 1 - $row.Id | Should Be 3 - $row.FirstName | Should Be "mary jo" - $row.LastName | Should Be "soe" - $row.YearsInMS | Should Be 5 + $row.Id | Should -Be 3 + $row.FirstName | Should -Be "mary jo" + $row.LastName | Should -Be "soe" + $row.YearsInMS | Should -Be 5 } } @@ -300,18 +300,18 @@ Describe "DataRow and DataRowView Adapter tests" -tags "CI" { It "Should be able to access data columns" { $rowView = $dataTable.DefaultView[1] - $rowView.Id | Should Be 2 - $rowView.FirstName | Should Be "paul" - $rowView.LastName | Should Be "smith" - $rowView.YearsInMS | Should Be 15 + $rowView.Id | Should -Be 2 + $rowView.FirstName | Should -Be "paul" + $rowView.LastName | Should -Be "smith" + $rowView.YearsInMS | Should -Be 15 } It "DataView should be enumerable" { $rowView = $dataTable.DefaultView | Select-Object -Last 1 - $rowView.Id | Should Be 4 - $rowView.FirstName | Should Be "edmund`todd `n" - $rowView.LastName | Should Be "bush" - $rowView.YearsInMS | Should Be 9 + $rowView.Id | Should -Be 4 + $rowView.FirstName | Should -Be "edmund`todd `n" + $rowView.LastName | Should -Be "bush" + $rowView.YearsInMS | Should -Be 9 } } } diff --git a/test/powershell/engine/ETS/CimAdapter.Tests.ps1 b/test/powershell/engine/ETS/CimAdapter.Tests.ps1 index fb784a4390d..aadc08e8606 100644 --- a/test/powershell/engine/ETS/CimAdapter.Tests.ps1 +++ b/test/powershell/engine/ETS/CimAdapter.Tests.ps1 @@ -37,53 +37,53 @@ try { } It "Namespace-qualified Win32_Process is present" -skip:(!$IsWindows) { - $indexOf_namespaceQualified_Win32Process |Should not Be (-1) + $indexOf_namespaceQualified_Win32Process | Should -Not -Be (-1) } It "Namespace-qualified CIM_Process is present" { - $indexOf_namespaceQualified_CimProcess |Should not Be (-1) + $indexOf_namespaceQualified_CimProcess | Should -Not -Be (-1) } It "Namespace-qualified CIM_LogicalElement is present" { - $indexOf_namespaceQualified_CimLogicalElement |Should not Be (-1) + $indexOf_namespaceQualified_CimLogicalElement | Should -Not -Be (-1) } It "Namespace-qualified CIM_ManagedSystemElement is present" { - $indexOf_namespaceQualified_CimManagedSystemElement |Should not Be (-1) + $indexOf_namespaceQualified_CimManagedSystemElement | Should -Not -Be (-1) } It "Classname of Win32_Process is present" -skip:(!$IsWindows) { - $indexOf_className_Win32Process |Should not Be (-1) + $indexOf_className_Win32Process | Should -Not -Be (-1) } It "Classname of CIM_Process is present" { - $indexOf_className_CimProcess |Should not Be (-1) + $indexOf_className_CimProcess | Should -Not -Be (-1) } It "Classname of CIM_LogicalElement is present" { - $indexOf_className_CimLogicalElement |Should not Be (-1) + $indexOf_className_CimLogicalElement | Should -Not -Be (-1) } It "Classname of CIM_ManagedSystemElement is present" { - $indexOf_className_CimManagedSystemElement |Should not Be (-1) + $indexOf_className_CimManagedSystemElement | Should -Not -Be (-1) } It "Win32_Process comes after CIM_Process (namespace qualified)" -skip:(!$IsWindows) { - $indexOf_namespaceQualified_Win32Process |should belessthan $indexOf_namespaceQualified_CimProcess + $indexOf_namespaceQualified_Win32Process | Should -BeLessThan $indexOf_namespaceQualified_CimProcess } It "CIM_Process comes after CIM_LogicalElement (namespace qualified)" { - $indexOf_namespaceQualified_CimProcess |should belessthan $indexOf_namespaceQualified_CimLogicalElement + $indexOf_namespaceQualified_CimProcess | Should -BeLessThan $indexOf_namespaceQualified_CimLogicalElement } It "CIM_LogicalElement comes after CIM_ManagedSystemElement (namespace qualified)" { - $indexOf_namespaceQualified_CimLogicalElement |should belessthan $indexOf_namespaceQualified_CimManagedSystemElement + $indexOf_namespaceQualified_CimLogicalElement | Should -BeLessThan $indexOf_namespaceQualified_CimManagedSystemElement } It "Win32_Process comes after CIM_Process (classname only)" -skip:(!$IsWindows) { - $indexOf_className_Win32Process |should belessthan $indexOf_className_CimProcess + $indexOf_className_Win32Process | Should -BeLessThan $indexOf_className_CimProcess } It "CIM_Process comes after CIM_LogicalElement (classname only)" { - $indexOf_className_CimProcess |should belessthan $indexOf_className_CimLogicalElement + $indexOf_className_CimProcess | Should -BeLessThan $indexOf_className_CimLogicalElement } It "CIM_LogicalElement comes after CIM_ManagedSystemElement (classname only)" { - $indexOf_className_CimLogicalElement |should belessthan $indexOf_className_CimManagedSystemElement + $indexOf_className_CimLogicalElement | Should -BeLessThan $indexOf_className_CimManagedSystemElement } It "Namespace qualified PSTypenames comes after class-only PSTypeNames" -skip:(!$IsWindows) { - $indexOf_namespaceQualified_CimManagedSystemElement |should belessthan $indexOf_className_Win32Process + $indexOf_namespaceQualified_CimManagedSystemElement | Should -BeLessThan $indexOf_className_Win32Process } } } diff --git a/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 index ffa094722f2..81ad67404bf 100644 --- a/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 @@ -39,7 +39,7 @@ Describe 'Online help tests for PowerShell Core Cmdlets' -Tags "CI" { It "Validate 'get-help $($cmdlet.TopicTitle) -Online'" -Skip:$skipTest { $actualURI = Get-Help $cmdlet.TopicTitle -Online $actualURI = $actualURI.Replace("Help URI: ","") - $actualURI | Should Be $cmdlet.HelpURI + $actualURI | Should -Be $cmdlet.HelpURI } } } @@ -82,7 +82,7 @@ Describe 'Get-Help -Online opens the default web browser and navigates to the cm } It "Get-Help get-process -online" -skip:$skipTest { - { Get-Help get-process -online } | Should Not Throw + { Get-Help get-process -online } | Should -Not -Throw } } @@ -99,7 +99,7 @@ Describe 'Get-Help -Online is not supported on Nano Server and IoT' -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | Should Be "InvalidOperation,Microsoft.PowerShell.Commands.GetHelpCommand" + $_.FullyQualifiedErrorId | Should -Be "InvalidOperation,Microsoft.PowerShell.Commands.GetHelpCommand" } } } diff --git a/test/powershell/engine/Help/HelpSystem.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.Tests.ps1 index 27f4cb39de0..cb569a17437 100644 --- a/test/powershell/engine/Help/HelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.Tests.ps1 @@ -52,8 +52,8 @@ function RunTestCase It "Validate -Description and -Examples sections in help content. Run 'Get-help -name $cmdletName'" { $help = get-help -name $cmdletName - $help.Description | Out-String | Should Match $cmdletName - $help.Examples | Out-String | Should Match $cmdletName + $help.Description | Out-String | Should -Match $cmdletName + $help.Examples | Out-String | Should -Match $cmdletName } if ($tag -eq "CI") @@ -71,9 +71,9 @@ Describe "Validate that //default.help.txt is present" -Tags @( It "Get-Help returns information about the help system." { $help = Get-Help - $help.Name | Should Be "default" - $help.Category | Should Be "HelpFile" - $help.Synopsis | Should Match "SHORT DESCRIPTION" + $help.Name | Should -Be "default" + $help.Category | Should -Be "HelpFile" + $help.Synopsis | Should -Match "SHORT DESCRIPTION" } } @@ -169,7 +169,7 @@ Describe "Validate that Get-Help returns provider-specific help" -Tags @('CI', ' It -Pending:$pending "Shows contextual help when Get-Help is invoked for provider-specific path (Get-Help -Name $verb-$noun -Path $path)" { # Path should exist or else Get-Help will fallback to default help text - $path | Should Exist + $path | Should -Exist $xpath = "/msh:helpItems/msh:providerHelp/msh:CmdletHelpPaths/msh:CmdletHelpPath$helpContext/command:command/command:details[command:verb='$verb' and command:noun='$noun']" $helpXmlNode = Select-Xml -Path $helpFile -XPath $xpath -Namespace $namespaces | Select-Object -ExpandProperty Node @@ -179,7 +179,7 @@ Describe "Validate that Get-Help returns provider-specific help" -Tags @('CI', ' # System.Management.Automation.ProviderContext.GetProviderSpecificHelpInfo ignores extra whitespace, line breaks and # comments when loading help XML, but Select-Xml can not; use BeLikeExactly operator to omit trailing line breaks: - $helpXmlNode.description.para -clike "$expected*" | Should Be $true + $helpXmlNode.description.para -clike "$expected*" | Should -Be $true } } } @@ -210,13 +210,13 @@ Describe "Validate about_help.txt under culture specific folder works" -Tags @(' It "Get-Help should return help text and not multiple HelpInfo objects when help is under `$pshome path" { $help = Get-Help about_testhelp - $help.count | Should Be 1 - $help | Should BeExactly "Hello" + $help.count | Should -Be 1 + $help | Should -BeExactly "Hello" } It "Get-Help for about_Variable should return only one help object" { $help = Get-Help about_Variables - $help.count | Should Be 1 + $help.count | Should -Be 1 } } @@ -236,7 +236,7 @@ Describe "Get-Help should find help info within help files" -Tags @('CI', 'Requi { $null = New-Item -ItemType File -Path $helpFilePath -Value "about_test" -ErrorAction SilentlyContinue $helpContent = Get-Help about_testCase - $helpContent | Should Match "about_test" + $helpContent | Should -Match "about_test" } finally { @@ -282,7 +282,7 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { $command, $result ) - $command.Invoke() | Should Be $result + $command.Invoke() | Should -Be $result } } @@ -293,36 +293,36 @@ Describe "Get-Help should find pattern alias" -Tags "CI" { } It "Get-Help should find alias as command" { - (Get-Help where).Name | Should BeExactly "Where-Object" + (Get-Help where).Name | Should -BeExactly "Where-Object" } It "Get-Help should find alias with ? pattern" { $help = Get-Help wher? - $help.Category | Should BeExactly "Alias" - $help.Synopsis | Should BeExactly "Where-Object" + $help.Category | Should -BeExactly "Alias" + $help.Synopsis | Should -BeExactly "Where-Object" } It "Get-Help should find alias with * pattern" { Set-Alias -Name testAlias1 -Value Where-Object $help = Get-Help testAlias1* - $help.Category | Should BeExactly "Alias" - $help.Synopsis | Should BeExactly "Where-Object" + $help.Category | Should -BeExactly "Alias" + $help.Synopsis | Should -BeExactly "Where-Object" } } Describe "help function uses full view by default" -Tags "CI" { It "help should return full view without -Full switch" { $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process) - $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should Not BeNullOrEmpty + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should -Not -BeNullOrEmpty } It "help should return full view even with -Full switch" { $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process -Full) - $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should Not BeNullOrEmpty + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should -Not -BeNullOrEmpty } It "help should not append -Full when not using AllUsersView parameter set" { $gpsHelp = (help Microsoft.PowerShell.Management\Get-Process -Parameter Name) - $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should BeNullOrEmpty + $gpsHelp | Where-Object {$_ -cmatch '^PARAMETERS'} | Should -BeNullOrEmpty } } diff --git a/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 b/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 index 8ba828c37c9..c87044f74f8 100644 --- a/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 @@ -156,11 +156,11 @@ function ValidateInstalledHelpContent $helpFilesInstalled = @(GetFiles -path $testCases[$moduleName].HelpInstallationPath | ForEach-Object {Split-Path $_ -Leaf}) $expectedHelpFiles = @($testCases[$moduleName].HelpFiles) - $helpFilesInstalled.Count | Should Be $expectedHelpFiles.Count + $helpFilesInstalled.Count | Should -Be $expectedHelpFiles.Count foreach ($fileName in $expectedHelpFiles) { - $helpFilesInstalled -contains $fileName | Should Be $true + $helpFilesInstalled -contains $fileName | Should -Be $true } } @@ -269,11 +269,11 @@ function ValidateSaveHelp $compressedFile = GetFiles -fileType "*$extension" -path $path | ForEach-Object {Split-Path $_ -Leaf} $expectedCompressedFile = $testCases[$moduleName].CompressedFiles - $expectedCompressedFile | Should Be $compressedFile + $expectedCompressedFile | Should -Be $compressedFile $helpInfoFile = GetFiles -fileType "*HelpInfo.xml" -path $path | ForEach-Object {Split-Path $_ -Leaf} $expectedHelpInfoFile = $testCases[$moduleName].HelpInfoFiles - $expectedHelpInfoFile | Should Be $helpInfoFile + $expectedHelpInfoFile | Should -Be $helpInfoFile } Describe "Validate Update-Help from the Web for one PowerShell Core module." -Tags @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') { diff --git a/test/powershell/engine/Job/Jobs.Tests.ps1 b/test/powershell/engine/Job/Jobs.Tests.ps1 index 72eb53a0f44..afd25a320a0 100644 --- a/test/powershell/engine/Job/Jobs.Tests.ps1 +++ b/test/powershell/engine/Job/Jobs.Tests.ps1 @@ -10,12 +10,12 @@ Describe 'Basic Job Tests' -Tags 'CI' { function script:ValidateJobInfo($job, $state, $hasMoreData, $command) { - $job.State | Should BeExactly $state - $job.HasMoreData | Should Be $hasMoreData + $job.State | Should -BeExactly $state + $job.HasMoreData | Should -Be $hasMoreData if($command -ne $null) { - $job.Command | Should BeExactly $command + $job.Command | Should -BeExactly $command } } } @@ -34,48 +34,48 @@ Describe 'Basic Job Tests' -Tags 'CI' { $job = Start-Job -ScriptBlock { 1 + 1 } $result = $job | Wait-Job | Receive-Job ValidateJobInfo -job $job -state 'Completed' -hasMoreData $false -command ' 1 + 1 ' - $result | Should Be 2 + $result | Should -Be 2 } It 'Can run nested jobs' { $job = Start-Job -ScriptBlock { Start-Job -ScriptBlock { 1 + 1 } | Wait-Job | Receive-Job } ValidateJobInfo -job $job -state 'Running' -hasMoreData $true -command ' Start-Job -ScriptBlock { 1 + 1 } | Wait-Job | Receive-Job ' $result = $job | Wait-Job | Receive-Job - $result | Should Be 2 + $result | Should -Be 2 } It 'Can get errors messages from job' { $job = Start-Job -ScriptBlock { throw 'MyError' } | Wait-Job Receive-Job -Job $job -ErrorVariable ev -ErrorAction SilentlyContinue - $ev[0].Exception.Message | Should BeExactly 'MyError' + $ev[0].Exception.Message | Should -BeExactly 'MyError' } It 'Can get warning messages from job' { $job = Start-Job -ScriptBlock { Write-Warning 'MyWarning' } | Wait-Job Receive-Job -Job $job -WarningVariable wv -WarningAction SilentlyContinue - $wv | Should BeExactly 'MyWarning' + $wv | Should -BeExactly 'MyWarning' } It 'Can get verbose message from job' { $job = Start-Job -ScriptBlock { Write-Verbose -Verbose 'MyVerbose' } | Wait-Job $VerboseMsg = $job.ChildJobs[0].verbose.readall() - $VerboseMsg | Should BeExactly 'MyVerbose' + $VerboseMsg | Should -BeExactly 'MyVerbose' } It 'Can get progress message from job' { $job = Start-Job -ScriptBlock { Write-Progress -Activity 1 -Status 2 } | Wait-Job $ProgressMsg = $job.ChildJobs[0].progress.readall() - $ProgressMsg[0].Activity | Should BeExactly 1 - $ProgressMsg[0].StatusDescription | Should BeExactly 2 + $ProgressMsg[0].Activity | Should -BeExactly 1 + $ProgressMsg[0].StatusDescription | Should -BeExactly 2 } It "Create job with native command" { try { $nativeJob = Start-job { pwsh -c 1+1 } $nativeJob | Wait-Job - $nativeJob.State | Should BeExactly "Completed" - $nativeJob.HasMoreData | Should Be $true - Receive-Job $nativeJob | Should BeExactly 2 + $nativeJob.State | Should -BeExactly "Completed" + $nativeJob.HasMoreData | Should -Be $true + Receive-Job $nativeJob | Should -BeExactly 2 Remove-Job $nativeJob { Get-Job $nativeJob -ErrorAction Stop } | ShouldBeErrorId "JobWithSpecifiedNameNotFound,Microsoft.PowerShell.Commands.GetJobCommand" } @@ -113,9 +113,9 @@ Describe 'Basic Job Tests' -Tags 'CI' { ValidateJobInfo -job $waitedJob -state 'Completed' -hasMoreData $true -command ' Start-Sleep -Seconds $using:seconds ; $using:seconds' $result = $waitedJob | Receive-Job ## We check for $result to be less than 4 so that any of the jobs completing first will considered a success. - $result | Should BeLessThan 4 + $result | Should -BeLessThan 4 ## Check none of the jobs threw errors. - $jobs.Error | Should BeNullOrEmpty + $jobs.Error | Should -BeNullOrEmpty } It 'Can timeout waiting for a job' { @@ -128,40 +128,40 @@ Describe 'Basic Job Tests' -Tags 'CI' { Context 'Receive-job tests' { It 'Can Receive-Job with state change events' { $result = Start-Job -Name 'ReceiveWriteEventsJob' -ScriptBlock { 1 + 1 } | Receive-Job -Wait -WriteEvents - $result.Count | Should Be 3 - $result[0] | Should Be 2 - $result[1].GetType().FullName | Should BeExactly 'System.Management.Automation.JobStateEventArgs' + $result.Count | Should -Be 3 + $result[0] | Should -Be 2 + $result[1].GetType().FullName | Should -BeExactly 'System.Management.Automation.JobStateEventArgs' } It 'Can Receive-Job with job object and result' { $result = Start-Job -ScriptBlock { 1 + 1 } | Receive-Job -Wait -WriteJobInResults - $result.Count | Should Be 2 + $result.Count | Should -Be 2 ValidateJobInfo -job $result[0] -command ' 1 + 1 ' -state 'Completed' -hasMoreData $false - $result[1] | Should Be 2 + $result[1] | Should -Be 2 $result[0] | Remove-Job -Force -ErrorAction SilentlyContinue } It 'Can Receive-Job and autoremove' { $result = Start-Job -Name 'ReceiveJobAutoRemove' -ScriptBlock { 1 + 1 } | Receive-Job -Wait -AutoRemoveJob - $result | Should Be 2 + $result | Should -Be 2 { Get-Job -Name 'ReceiveJobAutoRemove' -ErrorAction Stop } | ShouldBeErrorId 'JobWithSpecifiedNameNotFound,Microsoft.PowerShell.Commands.GetJobCommand' } It 'Can Receive-Job and keep results' { $job = Start-Job -ScriptBlock { 1 + 1 } | Wait-Job $result = Receive-Job -Keep -Job $job - $result | Should Be 2 + $result | Should -Be 2 $result2 = Receive-Job -Job $job - $result2 | Should Be 2 + $result2 | Should -Be 2 $result3 = Receive-Job -Job $job - $result3 | Should BeNullOrEmpty + $result3 | Should -BeNullOrEmpty $job | Remove-Job -Force -ErrorAction SilentlyContinue } It 'Can Receive-Job with NoRecurse' { $job = Start-Job -ScriptBlock { 1 + 1 } $result = Receive-Job -Wait -NoRecurse -Job $job - $result | Should BeNullOrEmpty + $result | Should -BeNullOrEmpty $job | Remove-Job -Force -ErrorAction SilentlyContinue } @@ -169,7 +169,7 @@ Describe 'Basic Job Tests' -Tags 'CI' { $jobName = 'ReceiveUsingComputerName' $job = Start-Job -ScriptBlock { 1 + 1 } -Name $jobName | Wait-Job $result = Receive-Job -ComputerName localhost -Job $job - $result | Should Be 2 + $result | Should -Be 2 $job | Remove-Job -Force -ErrorAction SilentlyContinue } @@ -177,7 +177,7 @@ Describe 'Basic Job Tests' -Tags 'CI' { $jobName = 'ReceiveUsingLocation' $job = Start-Job -ScriptBlock { 1 + 1 } -Name $jobName | Wait-Job $result = Receive-Job -Location localhost -Job $job - $result | Should Be 2 + $result | Should -Be 2 $job | Remove-Job -Force -ErrorAction SilentlyContinue } @@ -185,7 +185,7 @@ Describe 'Basic Job Tests' -Tags 'CI' { $job = Start-Job -ScriptBlock { 1 + 1 } $result = $job | Receive-Job -Wait ValidateJobInfo -job $job -state 'Completed' -hasMoreData $false -command ' 1 + 1 ' - $result | Should Be 2 + $result | Should -Be 2 } } @@ -229,7 +229,7 @@ Describe 'Basic Job Tests' -Tags 'CI' { It 'Can Get-Job with ' -TestCases $getJobChildJobs { param($parameters) $jobs = Get-Job @parameters - $jobs.Count | Should Be 2 + $jobs.Count | Should -Be 2 ValidateJobInfo -job $jobs[0] -state 'Completed' -hasMoreData $true -Name 'StartedJob' ValidateJobInfo -job $jobs[1] -state 'Completed' -hasMoreData $true } @@ -253,7 +253,7 @@ Describe 'Basic Job Tests' -Tags 'CI' { $jobToRemove = Start-Job -ScriptBlock { 1 + 1 } -Name 'JobToRemove' | Wait-Job $splat = @{ $property = $jobToRemove.$property } Remove-Job @splat - Get-Job $jobToRemove -ErrorAction SilentlyContinue | Should BeNullOrEmpty + Get-Job $jobToRemove -ErrorAction SilentlyContinue | Should -BeNullOrEmpty } } diff --git a/test/powershell/engine/Module/ModulePath.Tests.ps1 b/test/powershell/engine/Module/ModulePath.Tests.ps1 index 6dd7142d678..a2247bcd3ca 100644 --- a/test/powershell/engine/Module/ModulePath.Tests.ps1 +++ b/test/powershell/engine/Module/ModulePath.Tests.ps1 @@ -48,10 +48,10 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { $paths = $defaultModulePath -split [System.IO.Path]::PathSeparator - $paths.Count | Should Be 3 - $paths[0].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should Be $expectedUserPath - $paths[1].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should Be $expectedSharedPath - $paths[2].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should Be $expectedSystemPath + $paths.Count | Should -Be 3 + $paths[0].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should -Be $expectedUserPath + $paths[1].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should -Be $expectedSharedPath + $paths[2].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should -Be $expectedSystemPath } It "ignore pshome module path derived from a different powershell core instance" -Skip:(!$IsCoreCLR) { @@ -68,10 +68,10 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { $newModulePath = & $powershell -nopro -c '$env:PSModulePath' $paths = $newModulePath -split [System.IO.Path]::PathSeparator - $paths.Count | Should Be 3 - $paths[0] | Should Be $expectedUserPath - $paths[1] | Should Be $expectedSharedPath - $paths[2] | Should Be $expectedSystemPath + $paths.Count | Should -Be 3 + $paths[0] | Should -Be $expectedUserPath + $paths[1] | Should -Be $expectedSharedPath + $paths[2] | Should -Be $expectedSystemPath } finally { @@ -89,9 +89,9 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { $newModulePath = & $powershell -nopro -c '$env:PSModulePath' $paths = $newModulePath -split [System.IO.Path]::PathSeparator - $paths.Count | Should Be 5 - $paths -contains $fakePSHomeModuleDir | Should Be $true - $paths -contains $customeModules | Should Be $true + $paths.Count | Should -Be 5 + $paths -contains $fakePSHomeModuleDir | Should -Be $true + $paths -contains $customeModules | Should -Be $true } } diff --git a/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 b/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 index 6cbde262bd8..b6bf9d96137 100644 --- a/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 +++ b/test/powershell/engine/Module/NewModuleManifest.Tests.ps1 @@ -24,16 +24,16 @@ Describe "New-ModuleManifest tests" -tags "CI" { New-ModuleManifest -Path $testModulePath -ProjectUri $testUri -LicenseUri $testUri -IconUri $testUri -HelpInfoUri $testUri $module = Test-ModuleManifest -Path $testModulePath - $module.HelpInfoUri | Should BeExactly $absoluteUri - $module.PrivateData.PSData.IconUri | Should BeExactly $absoluteUri - $module.PrivateData.PSData.LicenseUri | Should BeExactly $absoluteUri - $module.PrivateData.PSData.ProjectUri | Should BeExactly $absoluteUri + $module.HelpInfoUri | Should -BeExactly $absoluteUri + $module.PrivateData.PSData.IconUri | Should -BeExactly $absoluteUri + $module.PrivateData.PSData.LicenseUri | Should -BeExactly $absoluteUri + $module.PrivateData.PSData.ProjectUri | Should -BeExactly $absoluteUri } function TestNewModuleManifestEncoding { param ([byte[]]$expected) New-ModuleManifest -Path $testModulePath - (Get-Content -AsByteStream -Path $testModulePath -TotalCount $expected.Length) -join ',' | Should Be ($expected -join ',') + (Get-Content -AsByteStream -Path $testModulePath -TotalCount $expected.Length) -join ',' | Should -Be ($expected -join ',') } It "Verify module manifest encoding" { diff --git a/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 b/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 index 1d823f35ab7..d5705d30ebd 100644 --- a/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 +++ b/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 @@ -43,7 +43,7 @@ Describe "Tests for paths of submodules in module manifest" -tags "CI" { New-ModuleManifest $moduleFilePath -NestedModules @($SubModulePath) Import-Module $moduleFilePath - (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should Be $true + (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -Be $true } It "Test if RootModule path is " -TestCases $testCases { @@ -51,6 +51,6 @@ Describe "Tests for paths of submodules in module manifest" -tags "CI" { New-ModuleManifest $moduleFilePath -RootModule $SubModulePath Import-Module $moduleFilePath - (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should Be $true + (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -Be $true } } diff --git a/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 b/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 index 53df7081dab..5c347fd46da 100644 --- a/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 +++ b/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 @@ -18,10 +18,10 @@ Describe "Test-ModuleManifest tests" -tags "CI" { New-ModuleManifest -NestedModules $fileList -RootModule foo\bar.psm1 -RequiredAssemblies $fileList -Path $testModulePath -TypesToProcess $fileList -FormatsToProcess $fileList -ScriptsToProcess $fileList -FileList $fileList -ModuleList $fileList - Test-Path $testModulePath | Should Be $true + Test-Path $testModulePath | Should -Be $true # use -ErrorAction Stop to cause test to fail if Test-ModuleManifest writes to error stream - Test-ModuleManifest -Path $testModulePath -ErrorAction Stop | Should BeOfType System.Management.Automation.PSModuleInfo + Test-ModuleManifest -Path $testModulePath -ErrorAction Stop | Should -BeOfType System.Management.Automation.PSModuleInfo } It "module manifest containing missing files returns error: " -TestCases ( @@ -63,8 +63,8 @@ Describe "Test-ModuleManifest tests" -tags "CI" { New-Item -ItemType File -Path testdrive:/module/$rootModuleValue New-ModuleManifest -Path $testModulePath -RootModule $rootModuleValue $moduleManifest = Test-ModuleManifest -Path $testModulePath -ErrorAction Stop - $moduleManifest | Should BeOfType System.Management.Automation.PSModuleInfo - $moduleManifest.RootModule | Should Be $rootModuleValue + $moduleManifest | Should -BeOfType System.Management.Automation.PSModuleInfo + $moduleManifest.RootModule | Should -Be $rootModuleValue } It "module manifest containing valid processed empty rootmodule file type fails: " -TestCases ( @@ -94,8 +94,8 @@ Describe "Test-ModuleManifest tests" -tags "CI" { New-ModuleManifest -Path $testModulePath -RootModule $rootModuleValue $moduleManifest = Test-ModuleManifest -Path $testModulePath -ErrorAction Stop - $moduleManifest | Should BeOfType System.Management.Automation.PSModuleInfo - $moduleManifest.RootModule | Should BeNullOrEmpty + $moduleManifest | Should -BeOfType System.Management.Automation.PSModuleInfo + $moduleManifest.RootModule | Should -BeNullOrEmpty } It "module manifest containing invalid rootmodule returns error: " -TestCases ( @@ -190,7 +190,7 @@ Describe "Tests for circular references in required modules" -tags "CI" { try { Import-Module $lastModule -ErrorAction Stop - Get-Module $lastModule | Should Not BeNullOrEmpty + Get-Module $lastModule | Should -Not -BeNullOrEmpty } finally { @@ -234,7 +234,7 @@ Describe "Test-ModuleManifest Performance bug followup" -tags "CI" { $verbose = $job.ChildJobs[0].Verbose.ReadAll() # Before the fix, all modules under $pshome will be imported and will be far more than 15 verbose messages. However, we cannot fix the number in case verbose message may vary. - $verbose.Count | Should BeLessThan 15 + $verbose.Count | Should -BeLessThan 15 } AfterAll { diff --git a/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 b/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 index eebbde90243..e2a3e49ff05 100644 --- a/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 @@ -27,7 +27,7 @@ Describe "BooleanParameterDCR Tests" -tags "CI" { param ( $inputTest, $expected ) [bool]$switchTestParam = $inputTest $result = ParserTestSwitchCmdlet -switchParam:$switchTestParam - $result | should be $expected + $result | should -Be $expected } $tests = @( @@ -39,16 +39,16 @@ Describe "BooleanParameterDCR Tests" -tags "CI" { param ( $inputTest, $expected ) [bool]$switchTestParam = $inputTest $result = ParserTestSwitchCmdlet -switchParam:$switchTestParam - $result | should be $expected + $result | should -Be $expected } It "Test that a nullable boolean is accepted for a boolean parameter." { [System.Nullable[System.Int32]] $nullBoolVar = $false $result = ParserTestBoolCmdlet2 $nullBoolVar - $result | should be $false + $result | should -Be $false $result = ParserTestBoolCmdlet2 -First:$nullBoolVar - $result | should be $false + $result | should -Be $false $result = ParserTestBoolCmdlet2 -First $nullBoolVar - $result | should be $false + $result | should -Be $false } } diff --git a/test/powershell/engine/ParameterBinding/NullableBooleanDCR.Tests.ps1 b/test/powershell/engine/ParameterBinding/NullableBooleanDCR.Tests.ps1 index 3a165a47b69..f55fb514aac 100644 --- a/test/powershell/engine/ParameterBinding/NullableBooleanDCR.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/NullableBooleanDCR.Tests.ps1 @@ -34,19 +34,19 @@ Describe "Nullable Boolean DCR Tests" -Tags "CI" { It 'Test a boolean parameter accepts positional values, input:, expect:' -TestCases $testCases { param($Arg, $Expected) - (parsertestfunction $Arg).Values[0] | Should Be $Expected - (parsertest-bool2 $Arg).Values[0] | Should Be $Expected + (parsertestfunction $Arg).Values[0] | Should -Be $Expected + (parsertest-bool2 $Arg).Values[0] | Should -Be $Expected } It 'Test a boolean parameter accepts values specified with a colon, input:, expect:' -TestCases $testCases { param($Arg, $Expected) - (parsertestfunction -First:$Arg).Values[0] | Should Be $Expected - (parsertest-bool2 -First:$Arg).Values[0] | Should Be $Expected + (parsertestfunction -First:$Arg).Values[0] | Should -Be $Expected + (parsertest-bool2 -First:$Arg).Values[0] | Should -Be $Expected } It 'Test a boolean parameter accepts values specified with general format, input:, expect:' -TestCases $testCases { param($Arg, $Expected) - (parsertestfunction -First $Arg).Values[0] | Should Be $Expected - (parsertest-bool2 -First $Arg).Values[0] | Should Be $Expected + (parsertestfunction -First $Arg).Values[0] | Should -Be $Expected + (parsertest-bool2 -First $Arg).Values[0] | Should -Be $Expected } } diff --git a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 index 9795b2aa046..bd156e6c2c5 100644 --- a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 @@ -21,7 +21,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | should be "AmbiguousPositionalParameterNoName,test-PositionalBinding1" + $_.FullyQualifiedErrorId | should -Be "AmbiguousPositionalParameterNoName,test-PositionalBinding1" } } @@ -71,9 +71,9 @@ Describe "Parameter Binding Tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | should be "ParameterArgumentValidationErrorEmptyStringNotAllowed,test-allownullattributes" - $_.CategoryInfo | Should match "ParameterBindingValidationException" - $_.Exception.Message | should match "Parameter3" + $_.FullyQualifiedErrorId | should -Be "ParameterArgumentValidationErrorEmptyStringNotAllowed,test-allownullattributes" + $_.CategoryInfo | Should -Match "ParameterBindingValidationException" + $_.Exception.Message | should -Match "Parameter3" } } @@ -97,9 +97,9 @@ Describe "Parameter Binding Tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | should be "MissingArgument,test-namedwithboolishargument" - $_.CategoryInfo | Should match "ParameterBindingException" - $_.Exception.Message | should match "Parameter2" + $_.FullyQualifiedErrorId | should -Be "MissingArgument,test-namedwithboolishargument" + $_.CategoryInfo | Should -Match "ParameterBindingException" + $_.Exception.Message | should -Match "Parameter2" } } @@ -116,7 +116,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { } $result = test-singleswitchparameter - $result | Should Be $false + $result | Should -Be $false } It "Verify that a bool parameter returns proper value" { @@ -132,10 +132,10 @@ Describe "Parameter Binding Tests" -Tags "CI" { } $result1 = test-singleboolparameter - $result1 | Should Be $false + $result1 | Should -Be $false $result2 = test-singleboolparameter -Parameter1:1 - $result2 | Should Be $true + $result2 | Should -Be $true } It "Should throw a exception when passing a string that can't be parsed by Int" { @@ -157,10 +157,10 @@ Describe "Parameter Binding Tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | should be "ParameterArgumentTransformationError,test-singleintparameter" - $_.CategoryInfo | Should match "ParameterBindingArgumentTransformationException" - $_.Exception.Message | should match "Input string was not in a correct format" - $_.Exception.Message | should match "Parameter1" + $_.FullyQualifiedErrorId | should -Be "ParameterArgumentTransformationError,test-singleintparameter" + $_.CategoryInfo | Should -Match "ParameterBindingArgumentTransformationException" + $_.Exception.Message | should -Match "Input string was not in a correct format" + $_.Exception.Message | should -Match "Parameter1" } } @@ -175,7 +175,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { } $result = test-supportsshouldprocess2 -Whatif - $result | Should Be 1 + $result | Should -Be 1 } It "Verify that ValueFromPipeline takes precedence over ValueFromPipelineByPropertyName without type coercion" { @@ -192,7 +192,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { } $result = '0123' | test-bindingorder2 - $result | Should Be "0123 - 0" + $result | Should -Be "0123 - 0" } It "Verify that a ScriptBlock object can be delay-bound to a parameter of type FileInfo with pipeline input" { @@ -209,7 +209,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { $testFile = Join-Path $TestDrive -ChildPath "testfile.txt" New-Item -Path $testFile -ItemType file -Force $result = Get-Item $testFile | test-scriptblockbindingfrompipeline -Parameter1 {$_} - $result | Should Be "testfile.txt" + $result | Should -Be "testfile.txt" } It "Verify that a dynamic parameter named WhatIf doesn't conflict if SupportsShouldProcess is false" { @@ -222,7 +222,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { ) } - { test-dynamicparameters3 -Parameter1 1 } | Should Not Throw + { test-dynamicparameters3 -Parameter1 1 } | Should -Not -Throw } It "Verify that an int can be bound to a parameter of type Array" { @@ -256,7 +256,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { } $result = test-collectionbinding1 -Parameter1 1 -Parameter2 2 - $result | Should Be "P1:Int32,1 P2:Int32,2" + $result | Should -Be "P1:Int32,1 P2:Int32,2" } It "Verify that a dynamic parameter and an alias can't have the same name" { @@ -276,10 +276,10 @@ Describe "Parameter Binding Tests" -Tags "CI" { } catch { - $_.FullyQualifiedErrorId | should be "ParameterNameConflictsWithAlias" - $_.CategoryInfo | Should match "MetadataException" - $_.Exception.Message | should match "Parameter1" - $_.Exception.Message | should match "Parameter2" + $_.FullyQualifiedErrorId | should -Be "ParameterNameConflictsWithAlias" + $_.CategoryInfo | Should -Match "MetadataException" + $_.Exception.Message | should -Match "Parameter1" + $_.Exception.Message | should -Match "Parameter2" } } @@ -317,18 +317,18 @@ Describe "Parameter Binding Tests" -Tags "CI" { It "Test dot-source should evaluate '`$PSScriptRoot' for parameter default value" { $result = . $test1File - $result | Should Be $expected + $result | Should -Be $expected $result = . $test2File - $result | Should Be $expected + $result | Should -Be $expected } It "Test 'powershell -File' should evaluate '`$PSScriptRoot' for parameter default value" { $result = & $psPath -NoProfile -File $test1File - $result | Should Be $expected + $result | Should -Be $expected $result = & $psPath -NoProfile -File $test2File - $result | Should Be $expected + $result | Should -Be $expected } } @@ -392,57 +392,57 @@ Describe "Parameter Binding Tests" -Tags "CI" { It "Binds properly when passing an explicit array to an advanced function" { $result = Test-BindingFunction 1,2,3 - $result.ArgumentCount | Should Be 3 - $result.Value[0] | Should Be 1 - $result.Value[1] | Should Be 2 - $result.Value[2] | Should Be 3 + $result.ArgumentCount | Should -Be 3 + $result.Value[0] | Should -Be 1 + $result.Value[1] | Should -Be 2 + $result.Value[2] | Should -Be 3 } It "Binds properly when passing multiple arguments to an advanced function" { $result = Test-BindingFunction 1 2 3 - $result.ArgumentCount | Should Be 3 - $result.Value[0] | Should Be 1 - $result.Value[1] | Should Be 2 - $result.Value[2] | Should Be 3 + $result.ArgumentCount | Should -Be 3 + $result.Value[0] | Should -Be 1 + $result.Value[1] | Should -Be 2 + $result.Value[2] | Should -Be 3 } It "Binds properly when passing an explicit array to a cmdlet" { $result = Test-BindingCmdlet 1,2,3 - $result.ArgumentCount | Should Be 3 - $result.Value[0] | Should Be 1 - $result.Value[1] | Should Be 2 - $result.Value[2] | Should Be 3 + $result.ArgumentCount | Should -Be 3 + $result.Value[0] | Should -Be 1 + $result.Value[1] | Should -Be 2 + $result.Value[2] | Should -Be 3 } It "Binds properly when passing multiple arguments to a cmdlet" { $result = Test-BindingCmdlet 1 2 3 - $result.ArgumentCount | Should Be 3 - $result.Value[0] | Should Be 1 - $result.Value[1] | Should Be 2 - $result.Value[2] | Should Be 3 + $result.ArgumentCount | Should -Be 3 + $result.Value[0] | Should -Be 1 + $result.Value[1] | Should -Be 2 + $result.Value[2] | Should -Be 3 } It "Binds properly when collections of type other than object[] are used on an advanced function" { $list = [Collections.Generic.List[int]](1..3) $result = Test-BindingFunction $list - $result.ArgumentCount | Should Be 3 - $result.Value[0] | Should Be 1 - $result.Value[1] | Should Be 2 - $result.Value[2] | Should Be 3 + $result.ArgumentCount | Should -Be 3 + $result.Value[0] | Should -Be 1 + $result.Value[1] | Should -Be 2 + $result.Value[2] | Should -Be 3 } It "Binds properly when collections of type other than object[] are used on a cmdlet" { $list = [Collections.Generic.List[int]](1..3) $result = Test-BindingCmdlet $list - $result.ArgumentCount | Should Be 3 - $result.Value[0] | Should Be 1 - $result.Value[1] | Should Be 2 - $result.Value[2] | Should Be 3 + $result.ArgumentCount | Should -Be 3 + $result.Value[0] | Should -Be 1 + $result.Value[1] | Should -Be 2 + $result.Value[2] | Should -Be 3 } } } diff --git a/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 b/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 index 14a6e875873..f230301be4a 100644 --- a/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 @@ -12,7 +12,7 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 0 ValidateScript = { param ($result) - $result.BoundParameters.Name.ConstantValue | Should Be 'abc' + $result.BoundParameters.Name.ConstantValue | Should -Be 'abc' } }, @{ @@ -22,8 +22,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 0 ValidateScript = { param ($result) - $result.BoundParameters.Name.Value | Should BeOfType ([ScriptBlockExpressionAst].FullName) - $result.BoundParameters.Name.Value.Extent.Text | Should Be '{abc}' + $result.BoundParameters.Name.Value | Should -BeOfType ([ScriptBlockExpressionAst].FullName) + $result.BoundParameters.Name.Value.Extent.Text | Should -Be '{abc}' } }, @{ @@ -33,8 +33,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 1 ValidateScript = { param ($result) - $result.BindingExceptions.Path.CommandElement.Extent.Text | Should Be '-Path' - $result.BindingExceptions.Path.BindingException.ErrorId | Should Be 'NamedParameterNotFound' + $result.BindingExceptions.Path.CommandElement.Extent.Text | Should -Be '-Path' + $result.BindingExceptions.Path.BindingException.ErrorId | Should -Be 'NamedParameterNotFound' } }, @{ @@ -44,9 +44,9 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 1 ValidateScript = { param ($result) - $result.BoundParameters.Name.ConstantValue | Should Be 'abc' - $result.BindingExceptions.Path.CommandElement.Extent.Text | Should Be '-Path' - $result.BindingExceptions.Path.BindingException.ErrorId | Should Be 'NamedParameterNotFound' + $result.BoundParameters.Name.ConstantValue | Should -Be 'abc' + $result.BindingExceptions.Path.CommandElement.Extent.Text | Should -Be '-Path' + $result.BindingExceptions.Path.BindingException.ErrorId | Should -Be 'NamedParameterNotFound' } }, @{ @@ -56,8 +56,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 0 ValidateScript = { param ($result) - $result.BoundParameters.Name.Value | Should BeOfType ([CommandParameterAst].FullName) - $result.BoundParameters.Name.Value.Extent.Text | Should Be '-abc' + $result.BoundParameters.Name.Value | Should -BeOfType ([CommandParameterAst].FullName) + $result.BoundParameters.Name.Value.Extent.Text | Should -Be '-abc' } }, @{ @@ -67,8 +67,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 1 ValidateScript = { param ($result) - $result.BoundParameters.Name.ConstantValue | Should Be 'aa' - $result.BindingExceptions.bb.BindingException.ErrorId | Should Be 'PositionalParameterNotFound' + $result.BoundParameters.Name.ConstantValue | Should -Be 'aa' + $result.BindingExceptions.bb.BindingException.ErrorId | Should -Be 'PositionalParameterNotFound' } }, @{ @@ -78,8 +78,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 0 ValidateScript = { param ($result) - $result.BoundParameters.Name.Value | Should BeOfType ([ArrayLiteralAst].FullName) - $result.BoundParameters.Name.Value.Extent.Text | Should Be 'aa,bb,cc' + $result.BoundParameters.Name.Value | Should -BeOfType ([ArrayLiteralAst].FullName) + $result.BoundParameters.Name.Value.Extent.Text | Should -Be 'aa,bb,cc' } }, @{ @@ -89,9 +89,9 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 0 ValidateScript = { param ($result) - $result.BoundParameters.Name.ConstantValue | Should Be $true - $result.BoundParameters.Recurse.ConstantValue | Should Be $true - $result.BoundParameters.Path.ConstantValue | Should Be 'abc' + $result.BoundParameters.Name.ConstantValue | Should -Be $true + $result.BoundParameters.Recurse.ConstantValue | Should -Be $true + $result.BoundParameters.Path.ConstantValue | Should -Be 'abc' } }, @{ @@ -101,9 +101,9 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 1 ValidateScript = { param ($result) - $result.BoundParameters.Name.ConstantValue | Should Be $true - $result.BindingExceptions.f.CommandElement.Extent.Text | Should Be '-f' - $result.BindingExceptions.f.BindingException.ErrorId | Should Be 'AmbiguousParameter' + $result.BoundParameters.Name.ConstantValue | Should -Be $true + $result.BindingExceptions.f.CommandElement.Extent.Text | Should -Be '-f' + $result.BindingExceptions.f.BindingException.ErrorId | Should -Be 'AmbiguousParameter' } }, @{ @@ -113,8 +113,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 1 ValidateScript = { param ($result) - $result.BindingExceptions.f.CommandElement.Extent.Text | Should Be '-f' - $result.BindingExceptions.f.BindingException.ErrorId | Should Be 'AmbiguousParameter' + $result.BindingExceptions.f.CommandElement.Extent.Text | Should -Be '-f' + $result.BindingExceptions.f.BindingException.ErrorId | Should -Be 'AmbiguousParameter' } } ) @@ -127,8 +127,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { $cmdAst = $ast.Find({$args[0] -is [CommandAst]}, $false) $result = [StaticParameterBinder]::BindCommand($cmdAst) - $result.BoundParameters.Count | Should Be $BoundParametersCount - $result.BindingExceptions.Count | Should Be $ExceptionCount + $result.BoundParameters.Count | Should -Be $BoundParametersCount + $result.BindingExceptions.Count | Should -Be $ExceptionCount . $ValidateScript $result } } diff --git a/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 b/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 index b2f02cff4f0..82d739de28e 100644 --- a/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 +++ b/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 @@ -190,7 +190,7 @@ Describe "Invoke-Command remote debugging tests" -Tags 'Feature' { AddParameter("RemoteDebug", $true). AddParameter("AsJob", $true) $result = $ps.Invoke() - $testDebugger.DebugStopCount | Should Be 0 + $testDebugger.DebugStopCount | Should -Be 0 } It "Verifies that synchronous 'Invoke-Command -RemoteDebug' invokes debugger" { @@ -200,14 +200,14 @@ Describe "Invoke-Command remote debugging tests" -Tags 'Feature' { AddParameter("ScriptBlock", $sb). AddParameter("RemoteDebug", $true) $result = $ps.Invoke() - $testDebugger.RunspaceDebugProcessingCount | Should Be 1 - $testDebugger.DebugStopCount | Should Be 1 + $testDebugger.RunspaceDebugProcessingCount | Should -Be 1 + $testDebugger.DebugStopCount | Should -Be 1 } It "Verifies the debugger 'CancelDebuggerProcessing' API method" { $rs.Debugger.CancelDebuggerProcessing() - $testDebugger.RunspaceDebugProcessCancelled | Should Be $true + $testDebugger.RunspaceDebugProcessCancelled | Should -Be $true } It "Verifies that 'Invoke-Command -RemoteDebug' running in a runspace without PSHost is ignored" { @@ -217,6 +217,6 @@ Describe "Invoke-Command remote debugging tests" -Tags 'Feature' { AddParameter("ScriptBlock", $sb). AddParameter("RemoteDebug", $true) $result = $ps2.Invoke() - $result | Should Be "Hello!" + $result | Should -Be "Hello!" } } diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 index 88cf35be5e2..d156e9ee40d 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 @@ -6,7 +6,7 @@ Describe "New-PSSession basic test" -Tag @("CI") { New-PSSession -ComputerName nonexistcomputer -Authentication Basic throw "New-PSSession should throw" } catch { - $_.FullyQualifiedErrorId | Should Be "InvalidOperation,Microsoft.PowerShell.Commands.NewPSSessionCommand" + $_.FullyQualifiedErrorId | Should -Be "InvalidOperation,Microsoft.PowerShell.Commands.NewPSSessionCommand" } } } @@ -43,7 +43,7 @@ Describe "JEA session Transcript script test" -Tag @("Feature", 'RequireAdminOnW [powershell]::Create().AddScript($scriptBlock).Invoke() $headerFile = Get-ChildItem $transScriptFile | Sort-Object LastWriteTime | Select-Object -Last 1 $header = Get-Content $headerFile | Out-String - $header | Should Match "Configuration Name: JEA" + $header | Should -Match "Configuration Name: JEA" } finally { @@ -82,7 +82,7 @@ Describe "JEA session Get-Help test" -Tag @("CI", 'RequireAdminOnWindows') { # Invoke the script block in a different PowerShell instance so that when TestDrive tries to delete $RoleCapDirectory, # the transcription has finished and the files are not locked. $helpContent = [powershell]::Create().AddScript($scriptBlock).Invoke() - $helpContent | Should Not Be $null + $helpContent | Should -Not -Be $null } finally { @@ -152,9 +152,9 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { function script:ValidateSessionInfo($session, $state) { - $session.ComputerName | Should BeExactly 'localhost' - $session.ConfigurationName | Should BeExactly $endPoint - $session.State | Should Be $state + $session.ComputerName | Should -BeExactly 'localhost' + $session.ConfigurationName | Should -BeExactly $endPoint + $session.State | Should -Be $state } } } @@ -188,8 +188,8 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { ValidateSessionInfo -session $session -state 'Disconnected' $result = Receive-PSSession -Session $session - $result | Should Be 2 - $result.PSComputerName | Should BeExactly 'localhost' + $result | Should -Be 2 + $result.PSComputerName | Should -BeExactly 'localhost' } finally { @@ -208,8 +208,8 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { Connect-RemoteSession -Session $session $result = Invoke-Command -Session $session -ScriptBlock { 1 + 1 } - $result | Should Be 2 - $result.PSComputerName | Should BeExactly 'localhost' + $result | Should -Be 2 + $result.PSComputerName | Should -BeExactly 'localhost' } finally { @@ -237,25 +237,25 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { } } - $result.Count | Should Be 1 - $result | Should Be 2 + $result.Count | Should -Be 1 + $result | Should -Be 2 } It 'Can execute command without creating new scope' { Invoke-Command -NoNewScope -ScriptBlock { $sameScopeVariable = 'SetInCurrentScope' } - $sameScopeVariable | Should BeExactly 'SetInCurrentScope' + $sameScopeVariable | Should -BeExactly 'SetInCurrentScope' } It 'Can execute command from a file' { $fileName = "$testdrive/remotingscript.ps1" '1 + 1' | Out-File $fileName $result = Invoke-Command -FilePath $fileName -Session $openSession - $result | Should Be 2 + $result | Should -Be 2 } It 'Can invoke-command as job' { $result = Invoke-Command -ScriptBlock { 1 + 1 } -Session $openSession -AsJob | Receive-Job -AutoRemoveJob -Wait - $result | Should Be 2 + $result | Should -Be 2 } It 'Can connect to all disconnected sessions by name' { @@ -279,7 +279,7 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { It 'Can pass values through $using' { $number = 100 $result = Invoke-Command -Session $openSession -ScriptBlock { $using:number } - $result | Should Be 100 + $result | Should -Be 100 } } diff --git a/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 b/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 index dd2a16f7878..531209a361d 100644 --- a/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 +++ b/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 @@ -55,7 +55,7 @@ Describe "Remote session configuration RoleDefintion RoleCapabilityFiles key tes { $fullyQualifiedErrorId = $psioe.ErrorRecord.FullyQualifiedErrorId } - $fullyQualifiedErrorId | Should Be 'CouldNotFindRoleCapabilityFile' + $fullyQualifiedErrorId | Should -Be 'CouldNotFindRoleCapabilityFile' } } @@ -78,7 +78,7 @@ Describe "Remote session configuration RoleDefintion RoleCapabilityFiles key tes { $fullyQualifiedErrorId = $psioe.ErrorRecord.FullyQualifiedErrorId } - $fullyQualifiedErrorId | Should Be 'InvalidRoleCapabilityFileExtension' + $fullyQualifiedErrorId | Should -Be 'InvalidRoleCapabilityFileExtension' } } @@ -105,7 +105,7 @@ Describe "Remote session configuration RoleDefintion RoleCapabilityFiles key tes { $exceptionTypeName = $_.Exception.InnerException.GetType().FullName } - $exceptionTypeName | Should Be 'System.Management.Automation.CommandNotFoundException' + $exceptionTypeName | Should -Be 'System.Management.Automation.CommandNotFoundException' } $ps.Dispose() diff --git a/test/powershell/engine/Remoting/SSHRemotingAPI.Tests.ps1 b/test/powershell/engine/Remoting/SSHRemotingAPI.Tests.ps1 index 2eaa9be66bf..9af74de0aef 100644 --- a/test/powershell/engine/Remoting/SSHRemotingAPI.Tests.ps1 +++ b/test/powershell/engine/Remoting/SSHRemotingAPI.Tests.ps1 @@ -41,7 +41,7 @@ Describe "SSH Remoting API Tests" -Tags "Feature" { } catch { - $_.Exception.InnerException.InnerException | Should BeOfType "System.IO.FileNotFoundException" + $_.Exception.InnerException.InnerException | Should -BeOfType "System.IO.FileNotFoundException" } } @@ -67,7 +67,7 @@ Describe "SSH Remoting API Tests" -Tags "Feature" { $expectedArgumentException = $_.Exception.InnerException } - $expectedArgumentException | Should BeOfType "System.ArgumentException" + $expectedArgumentException | Should -BeOfType "System.ArgumentException" } } } diff --git a/test/powershell/engine/Remoting/SSHRemotingCmdlets.Tests.ps1 b/test/powershell/engine/Remoting/SSHRemotingCmdlets.Tests.ps1 index d538fd58ba0..312268f6d61 100644 --- a/test/powershell/engine/Remoting/SSHRemotingCmdlets.Tests.ps1 +++ b/test/powershell/engine/Remoting/SSHRemotingCmdlets.Tests.ps1 @@ -25,7 +25,7 @@ Describe "SSHTransport switch parameter value" -Tags 'Feature' { } catch { - $_.FullyQualifiedErrorId | Should Match "ParameterArgumentValidationError" + $_.FullyQualifiedErrorId | Should -Match "ParameterArgumentValidationError" } } } @@ -53,7 +53,7 @@ Describe "SSHConnection parameter hashtable error conditions" -Tags 'Feature' { } catch { - $_.FullyQualifiedErrorId | Should Match "Argument,Microsoft.PowerShell.Commands.NewPSSessionCommand" + $_.FullyQualifiedErrorId | Should -Match "Argument,Microsoft.PowerShell.Commands.NewPSSessionCommand" } } } diff --git a/test/powershell/engine/Remoting/SessionOption.Tests.ps1 b/test/powershell/engine/Remoting/SessionOption.Tests.ps1 index 4689904e67b..1a7763a94a8 100644 --- a/test/powershell/engine/Remoting/SessionOption.Tests.ps1 +++ b/test/powershell/engine/Remoting/SessionOption.Tests.ps1 @@ -6,24 +6,24 @@ try { } Describe " WSMan SessionOption object" -Tag @("CI") { It "The SessionOption type exists" { - "Microsoft.WSMan.Management.SessionOption" -as "Type" | Should Not BeNullOrEmpty + "Microsoft.WSMan.Management.SessionOption" -as "Type" | Should -Not -BeNullOrEmpty } 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() - $result.SkipCACheck | should be $False - $result.SkipCNCheck | should be $False - $result.SkipRevocationCheck | should be $False - $result.UseEncryption | should be $True - $result.UseUtf16 | should be $False - $result.ProxyAuthentication | should be 0 - $result.SPNPort | should be 0 - $result.OperationTimeout | should be 0 - $result.ProxyCredential | should BeNullOrEmpty - $result.ProxyAccessType | should be ProxyIEConfig + $result.SkipCACheck | should -Be $False + $result.SkipCNCheck | should -Be $False + $result.SkipRevocationCheck | should -Be $False + $result.UseEncryption | should -Be $True + $result.UseUtf16 | should -Be $False + $result.ProxyAuthentication | should -Be 0 + $result.SPNPort | should -Be 0 + $result.OperationTimeout | should -Be 0 + $result.ProxyCredential | should -BeNullOrEmpty + $result.ProxyAccessType | should -Be ProxyIEConfig } It "The values of SessionOption may be set" { $result = [Microsoft.WSMan.Management.SessionOption]::new() @@ -38,16 +38,16 @@ try { $result.ProxyAccessType = "ProxyAutoDetect" $result.ProxyCredential = [System.Net.NetworkCredential]::new("user","pass") - $result.SkipCACheck | should be $true - $result.SkipCNCheck | should be $true - $result.SkipRevocationCheck | should be $true - $result.UseEncryption | should be $False - $result.UseUtf16 | should be $True - $result.ProxyAuthentication | should be "Negotiate" - $result.SPNPort | should be 10 - $result.OperationTimeout | should be 10 - $result.ProxyCredential | should Not BeNullOrEmpty - $result.ProxyAccessType | should be "ProxyAutoDetect" + $result.SkipCACheck | should -Be $true + $result.SkipCNCheck | should -Be $true + $result.SkipRevocationCheck | should -Be $true + $result.UseEncryption | should -Be $False + $result.UseUtf16 | should -Be $True + $result.ProxyAuthentication | should -Be "Negotiate" + $result.SPNPort | should -Be 10 + $result.OperationTimeout | should -Be 10 + $result.ProxyCredential | should -Not -BeNullOrEmpty + $result.ProxyAccessType | should -Be "ProxyAutoDetect" } } } diff --git a/test/powershell/engine/ResourceValidation/TestRunner.ps1 b/test/powershell/engine/ResourceValidation/TestRunner.ps1 index 99c4d798e21..85b9447c515 100644 --- a/test/powershell/engine/ResourceValidation/TestRunner.ps1 +++ b/test/powershell/engine/ResourceValidation/TestRunner.ps1 @@ -45,12 +45,12 @@ function Test-ResourceStrings $resourceType = $ASSEMBLY.GetType($classname, $false, $true) # the properties themselves are static internals, so we need # to using the appropriate bindingflags - $resourceType | Should Not BeNullOrEmpty + $resourceType | Should -Not -BeNullOrEmpty # check all the resource strings $xmlData = [xml](Get-Content $resourceFile.Fullname) foreach ( $inResource in $xmlData.root.data ) { - $resourceType.GetProperty($inResource.name,$bindingFlags).GetValue(0) | should be $inresource.value + $resourceType.GetProperty($inResource.name,$bindingFlags).GetValue(0) | Should -Be $inresource.value } } } From 6fbdd5971d07ba1dc228eb23b9e8fffd3230f828 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Tue, 6 Mar 2018 17:11:05 -0800 Subject: [PATCH 2/7] Tests syntax correction in engine. --- .../engine/Api/BasicEngine.Tests.ps1 | 4 +- .../engine/Api/InitialSessionState.Tests.ps1 | 12 ++-- .../engine/Api/LanguagePrimitive.Tests.ps1 | 10 ++-- .../engine/Api/TypeInference.Tests.ps1 | 32 +++++----- .../engine/Basic/Assembly.LoadFrom.ps1 | 10 ++-- .../engine/Basic/Credential.Tests.ps1 | 2 +- .../engine/Basic/DefaultCommands.Tests.ps1 | 10 ++-- .../engine/Basic/PropertyAccessor.Tests.ps1 | 2 +- .../engine/Basic/SemanticVersion.Tests.ps1 | 60 +++++++++---------- .../engine/Basic/ValidateAttributes.Tests.ps1 | 16 ++--- .../powershell/engine/COM/COM.Basic.Tests.ps1 | 2 +- test/powershell/engine/ETS/Adapter.Tests.ps1 | 8 +-- .../engine/Help/HelpSystem.Tests.ps1 | 2 +- .../engine/Help/UpdatableHelpSystem.Tests.ps1 | 2 +- test/powershell/engine/Job/Jobs.Tests.ps1 | 2 +- .../engine/Module/ModulePath.Tests.ps1 | 4 +- .../Module/SubmodulePathInManifest.Tests.ps1 | 4 +- .../Module/TestModuleManifest.Tests.ps1 | 2 +- .../BooleanParameterDCR.Tests.ps1 | 6 +- .../ParameterBinding.Tests.ps1 | 6 +- .../StaticParameterBinder.Tests.ps1 | 6 +- .../InvokeCommandRemoteDebug.Tests.ps1 | 2 +- .../Remoting/RemoteSession.Basic.Tests.ps1 | 2 +- .../engine/Remoting/SessionOption.Tests.ps1 | 20 +++---- 24 files changed, 113 insertions(+), 113 deletions(-) diff --git a/test/powershell/engine/Api/BasicEngine.Tests.ps1 b/test/powershell/engine/Api/BasicEngine.Tests.ps1 index 6d92bed8d1d..4f4f52eac0e 100644 --- a/test/powershell/engine/Api/BasicEngine.Tests.ps1 +++ b/test/powershell/engine/Api/BasicEngine.Tests.ps1 @@ -3,7 +3,7 @@ Describe 'Basic engine APIs' -Tags "CI" { Context 'powershell::Create' { It 'can create default instance' { - [powershell]::Create() | Should -Not -Be $null + [powershell]::Create() | Should -Not -BeNullOrEmpty } It "can load the default snapin 'Microsoft.WSMan.Management'" -skip:(-not $IsWindows) { @@ -12,7 +12,7 @@ Describe 'Basic engine APIs' -Tags "CI" { $result = $ps.Invoke() $result.Count | Should -Be 1 - $result[0].Source | Should -Be "Microsoft.WSMan.Management" + $result[0].Source | Should -BeExactly "Microsoft.WSMan.Management" } } diff --git a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 index 096a8d0dd5a..2602820a615 100644 --- a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 +++ b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 @@ -29,32 +29,32 @@ Describe "InitialSessionState capacity" -Tags CI { It "function capacity in initial session state should not be limited" { $ps.AddCommand('f4999').Invoke() | Should -Be "fn f4999" - $ps.Streams.Error | Should -Be $null + $ps.Streams.Error | Should -BeNullOrEmpty } It "alias capacity in initial session state should not be limited" { $ps.AddCommand('a4999').Invoke() | Should -Be "fn f4999" - $ps.Streams.Error | Should -Be $null + $ps.Streams.Error | Should -BeNullOrEmpty } It "variable capacity in initial session state should not be limited" { $ps.AddScript('$v4999').Invoke() | Should -Be "var v4999" - $ps.Streams.Error | Should -Be $null + $ps.Streams.Error | Should -BeNullOrEmpty } It "function capacity should not be limited after runspace is opened" { $ps.AddScript('function f5000 { "in f5000" } f5000').Invoke() | Should -Be "in f5000" - $ps.Streams.Error | Should -Be $null + $ps.Streams.Error | Should -BeNullOrEmpty } It "variable capacity should not be limited after runspace is opened" { $ps.AddScript('$v5000 = "var v5000"; $v5000').Invoke() | Should -Be "var v5000" - $ps.Streams.Error | Should -Be $null + $ps.Streams.Error | Should -BeNullOrEmpty } It "alias capacity should not be limited after runspace is opened" { $ps.AddScript('New-Alias -Name a5000 -Value f1; a5000').Invoke() | Should -Be "fn f1" - $ps.Streams.Error | Should -Be $null + $ps.Streams.Error | Should -BeNullOrEmpty } } diff --git a/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 b/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 index 2eb18d0b192..1108b1664fa 100644 --- a/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 +++ b/test/powershell/engine/Api/LanguagePrimitive.Tests.ps1 @@ -4,22 +4,22 @@ Describe "Language Primitive Tests" -Tags "CI" { It "Equality comparison with string and non-numeric type should not be culture sensitive" { $date = [datetime]'2005,3,10' $val = [System.Management.Automation.LanguagePrimitives]::Equals($date, "3/10/2005") - $val | Should -Be $true + $val | Should -BeTrue } It "Test conversion of an PSObject with Null Base Object to bool" { $mshObj = New-Object psobject - { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [bool]) } | Should -Be $true + { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [bool]) } | Should -BeTrue } It "Test conversion of an PSObject with Null Base Object to string" { $mshObj = New-Object psobject - { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [string]) -eq "" } | Should -Be $true + { [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [string]) -eq "" } | Should -BeTrue } It "Test conversion of an PSObject with Null Base Object to object" { $mshObj = New-Object psobject - { $mshObj -eq [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [Object]) } | Should -Be $true + { $mshObj -eq [System.Management.Automation.LanguagePrimitives]::ConvertTo($mshObj, [Object]) } | Should -BeTrue } It "Test Conversion of an IEnumerable to object[]" { @@ -30,6 +30,6 @@ Describe "Language Primitive Tests" -Tags "CI" { It "Casting recursive array to bool should not cause crash" { $a[0] = $a = [PSObject](,1) - [System.Management.Automation.LanguagePrimitives]::IsTrue($a) | Should -Be $true + [System.Management.Automation.LanguagePrimitives]::IsTrue($a) | Should -BeTrue } } diff --git a/test/powershell/engine/Api/TypeInference.Tests.ps1 b/test/powershell/engine/Api/TypeInference.Tests.ps1 index 2d2ce7128d6..9fd63d4999d 100644 --- a/test/powershell/engine/Api/TypeInference.Tests.ps1 +++ b/test/powershell/engine/Api/TypeInference.Tests.ps1 @@ -263,7 +263,7 @@ Describe "Type inference Tests" -tags "CI" { It "Infers type from where-object of integer" { $res = [AstTypeInference]::InferTypeOf( { [int[]] $i = 1..20; $i | Where-Object {$_ -gt 10} }.Ast) foreach ($r in $res) { - $r.Name -In 'System.Int32', 'System.Int32[]' | Should -Be $true + $r.Name -In 'System.Int32', 'System.Int32[]' | Should -BeTrue } } @@ -271,7 +271,7 @@ Describe "Type inference Tests" -tags "CI" { $res = [AstTypeInference]::InferTypeOf( { [int[]] $i = 1..20; $i | ForEach-Object {$_ * 10} }.Ast) $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -In 'System.Int32', 'System.Int32[]' | Should -Be $true + $r.Name -In 'System.Int32', 'System.Int32[]' | Should -BeTrue } } @@ -288,7 +288,7 @@ Describe "Type inference Tests" -tags "CI" { foreach ($r in $res) { $r.Name -In 'Microsoft.Management.Infrastructure.CimInstance#root/CIMV2/Win32_Bios', - 'Microsoft.Management.Infrastructure.CimInstance' | Should -Be $true + 'Microsoft.Management.Infrastructure.CimInstance' | Should -BeTrue } } @@ -296,7 +296,7 @@ Describe "Type inference Tests" -tags "CI" { $res = [AstTypeInference]::InferTypeOf( { [int[]] $i = 1..20; $i | ForEach-Object -Begin {"Hi"} {$_ * 10} -End {[int]} }.Ast) $res.Count | Should -Be 4 foreach ($r in $res) { - $r.Name -In 'System.Int32', 'System.Int32[]', 'System.String', 'System.Type' | Should -Be $true + $r.Name -In 'System.Int32', 'System.Int32[]', 'System.String', 'System.Type' | Should -BeTrue } } @@ -357,7 +357,7 @@ Describe "Type inference Tests" -tags "CI" { $gpsOutput = [Microsoft.PowerShell.Commands.GetProcessCommand].GetCustomAttributes([System.Management.Automation.OutputTypeAttribute], $false).Type $names = $gpsOutput.Name foreach ($r in $res) { - $r.Name -In $names | Should -Be $true + $r.Name -In $names | Should -BeTrue } } @@ -404,7 +404,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -In 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Int32', 'System.String' | Should -BeTrue } } @@ -419,7 +419,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -BeTrue } } @@ -434,7 +434,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -BeTrue } } @@ -449,7 +449,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -BeTrue } } @@ -464,7 +464,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -BeTrue } } @@ -479,7 +479,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -BeTrue } } @@ -494,7 +494,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -BeTrue } } @@ -507,7 +507,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -Be $true + $r.Name -In 'System.Type', 'System.Int32', 'System.String' | Should -BeTrue } } @@ -667,7 +667,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 3 foreach ($r in $res) { - $r.Name -In 'System.Int32', 'System.String', 'System.Type' | Should -Be $true + $r.Name -In 'System.Int32', 'System.String', 'System.Type' | Should -BeTrue } } @@ -756,7 +756,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -In 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should -Be $true + $r.Name -In 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should -BeTrue } } @@ -767,7 +767,7 @@ Describe "Type inference Tests" -tags "CI" { $res.Count | Should -Be 2 foreach ($r in $res) { - $r.Name -In 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should -Be $true + $r.Name -In 'System.IO.FileInfo', 'System.IO.DirectoryInfo' | Should -BeTrue } } } diff --git a/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 b/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 index 69c419e89aa..78cd468b434 100644 --- a/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 +++ b/test/powershell/engine/Basic/Assembly.LoadFrom.ps1 @@ -53,18 +53,18 @@ Describe "Assembly.LoadFrom Validation Test" -Tags "CI" { It "Assembly.LoadFrom should automatically load the implicit referenced assembly from the same folder" { ## Both types should not be available before loading the test assemblies - { [Assembly.Foo.Consumer] } | Should -Throw - { [Assembly.Bar.Provider] } | Should -Throw + { [Assembly.Foo.Consumer] } | Should -Throw -ErrorId "TypeNotFound" + { [Assembly.Bar.Provider] } | Should -Throw -ErrorId "TypeNotFound" ## The type 'Assembly.Foo.Consumer' should be available after loading 'Consumer.dll' [System.Reflection.Assembly]::LoadFrom($ConsumerAssembly) > $null [Assembly.Foo.Consumer].FullName | Should -Be "Assembly.Foo.Consumer" ## The type 'Assembly.Bar.Provider' should still not be available - { [Assembly.Bar.Provider] } | Should -Throw + { [Assembly.Bar.Provider] } | Should -Throw -ErrorId "TypeNotFound" ## Calling '[Assembly.Foo.Consumer]::GetName()' will trigger implicit loading of 'Provider.dll' and the call should work - [Assembly.Foo.Consumer]::GetName() | Should -Be "Assembly.Bar.Provider" + [Assembly.Foo.Consumer]::GetName() | Should -BeExactly "Assembly.Bar.Provider" ## Now the type 'Assembly.Bar.Provider' should be available - [Assembly.Bar.Provider].FullName | Should -Be "Assembly.Bar.Provider" + [Assembly.Bar.Provider].FullName | Should -BeExactly "Assembly.Bar.Provider" } } diff --git a/test/powershell/engine/Basic/Credential.Tests.ps1 b/test/powershell/engine/Basic/Credential.Tests.ps1 index 2db15c05c8d..237e924f9a0 100644 --- a/test/powershell/engine/Basic/Credential.Tests.ps1 +++ b/test/powershell/engine/Basic/Credential.Tests.ps1 @@ -3,6 +3,6 @@ Describe "Credential tests" -Tags "CI" { It "Explicit cast for an empty credential returns null" { # We should explicitly check that the expression returns $null - [PSCredential]::Empty.GetNetworkCredential() | Should -Be $null + [PSCredential]::Empty.GetNetworkCredential() | Should -BeNullOrEmpty } } diff --git a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 index f4435ad2db3..3171e6f5870 100644 --- a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 +++ b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 @@ -489,7 +489,7 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong aliases so we output them explicitly # if all aliases is Ok we output nothing $result | Write-Host - $result | Should -Be $null + $result | Should -BeNullOrEmpty } It "All approved aliases have the correct 'AllScope' option" { @@ -501,7 +501,7 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong aliases so we output them explicitly # if all aliases is Ok we output nothing $result | Write-Host - $result | Should -Be $null + $result | Should -BeNullOrEmpty } It "All approved aliases have the correct 'ReadOnly' option" { @@ -513,7 +513,7 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong aliases so we output them explicitly # if all aliases is Ok we output nothing $result | Write-Host - $result | Should -Be $null + $result | Should -BeNullOrEmpty } It "All approved Cmdlets present (no new Cmdlets added, no Cmdlets removed)" { @@ -525,10 +525,10 @@ Describe "Verify approved aliases list" -Tags "CI" { # Below 'Should Be' don't show full list wrong Cmdlets so we output them explicitly # if all Cmdlets is Ok we output nothing $result | Write-Host - $result | Should -Be $null + $result | Should -BeNullOrEmpty } It "Should have 'more' as a function" { - Test-Path Function:more | Should -Be $true + Test-Path Function:more | Should -BeTrue } } diff --git a/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 b/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 index 9465704b8be..eb0c322e0ce 100644 --- a/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 +++ b/test/powershell/engine/Basic/PropertyAccessor.Tests.ps1 @@ -95,7 +95,7 @@ try { It "Verify Writes Create the File if Not Present" { Remove-Item $userPropertiesFile -Force - Test-Path $userPropertiesFile | Should -Be $false + Test-Path $userPropertiesFile | Should -BeFalse Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass Get-Content -Path $userPropertiesFile | Should -Be '{"Microsoft.PowerShell:ExecutionPolicy":"Bypass"}' } diff --git a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 index 4cabf3a53b8..aaa87b2d0ee 100644 --- a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 +++ b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 @@ -115,37 +115,37 @@ Describe "SemanticVersion api tests" -Tags 'CI' { } It "Build meta should be ignored" { - $v1_0_0_beta -eq $v1_0_0_betaBuild | Should -Be $true - $v1_0_0_betaBuild -lt $v1_0_0_beta | Should -Be $false - $v1_0_0_beta -lt $v1_0_0_betaBuild | Should -Be $false + $v1_0_0_beta -eq $v1_0_0_betaBuild | Should -BeTrue + $v1_0_0_betaBuild -lt $v1_0_0_beta | Should -BeFalse + $v1_0_0_beta -lt $v1_0_0_betaBuild | Should -BeFalse } It " less than " -TestCases $testCases { param($lhs, $rhs) - $lhs -lt $rhs | Should -Be $true - $rhs -lt $lhs | Should -Be $false + $lhs -lt $rhs | Should -BeTrue + $rhs -lt $lhs | Should -BeFalse } It " less than or equal " -TestCases $testCases { param($lhs, $rhs) - $lhs -le $rhs | Should -Be $true - $rhs -le $lhs | Should -Be $false - $lhs -le $lhs | Should -Be $true - $rhs -le $rhs | Should -Be $true + $lhs -le $rhs | Should -BeTrue + $rhs -le $lhs | Should -BeFalse + $lhs -le $lhs | Should -BeTrue + $rhs -le $rhs | Should -BeTrue } It " greater than " -TestCases $testCases { param($lhs, $rhs) - $lhs -gt $rhs | Should -Be $false - $rhs -gt $lhs | Should -Be $true + $lhs -gt $rhs | Should -BeFalse + $rhs -gt $lhs | Should -BeTrue } It " greater than or equal " -TestCases $testCases { param($lhs, $rhs) - $lhs -ge $rhs | Should -Be $false - $rhs -ge $lhs | Should -Be $true - $lhs -ge $lhs | Should -Be $true - $rhs -ge $rhs | Should -Be $true + $lhs -ge $rhs | Should -BeFalse + $rhs -ge $lhs | Should -BeTrue + $lhs -ge $lhs | Should -BeTrue + $rhs -ge $rhs | Should -BeTrue } It "Equality " -TestCases @( @@ -153,23 +153,23 @@ Describe "SemanticVersion api tests" -Tags 'CI' { @{ operand = $v1_0_0_alpha } ) { param($operand) - $operand -eq $operand | Should -Be $true - $operand -ne $operand | Should -Be $false - $null -eq $operand | Should -Be $false - $operand -eq $null | Should -Be $false - $null -ne $operand | Should -Be $true - $operand -ne $null | Should -Be $true + $operand -eq $operand | Should -BeTrue + $operand -ne $operand | Should -BeFalse + $null -eq $operand | Should -BeFalse + $operand -eq $null | Should -BeFalse + $null -ne $operand | Should -BeTrue + $operand -ne $null | Should -BeTrue } It "comparisons with null" { - $v1_0_0 -lt $null | Should -Be $false - $null -lt $v1_0_0 | Should -Be $true - $v1_0_0 -le $null | Should -Be $false - $null -le $v1_0_0 | Should -Be $true - $v1_0_0 -gt $null | Should -Be $true - $null -gt $v1_0_0 | Should -Be $false - $v1_0_0 -ge $null | Should -Be $true - $null -ge $v1_0_0 | Should -Be $false + $v1_0_0 -lt $null | Should -BeFalse + $null -lt $v1_0_0 | Should -BeTrue + $v1_0_0 -le $null | Should -BeFalse + $null -le $v1_0_0 | Should -BeTrue + $v1_0_0 -gt $null | Should -BeTrue + $null -gt $v1_0_0 | Should -BeFalse + $v1_0_0 -ge $null | Should -BeTrue + $null -ge $v1_0_0 | Should -BeFalse } } @@ -212,7 +212,7 @@ Describe "SemanticVersion api tests" -Tags 'CI' { } $semVer = $null [SemanticVersion]::TryParse($_, [ref]$semVer) | Should -Be $expectedResult - $semVer | Should -Be $null + $semVer | Should -BeNullOrEmpty } It "Negative version arguments" { diff --git a/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 b/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 index 0c07483a2dd..471e30ab837 100644 --- a/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 +++ b/test/powershell/engine/Basic/ValidateAttributes.Tests.ps1 @@ -368,7 +368,7 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { It "'ValidateNotNull' should throw on null element of a collection argument" { ## Should throw on null element - { NotNullFunc -Value @("string", $null, 2) } | Should -Throw + { NotNullFunc -Value @("string", $null, 2) } | Should -Throw -ErrorId "ParameterArgumentValidationError,NotNullFunc" ## Should not throw on empty string element { NotNullFunc -Value @("string", "", 2) } | Should -Not -Throw ## Should not throw on an empty collection @@ -376,16 +376,16 @@ Describe 'Validate Attributes Tests' -Tags 'CI' { } It "'ValidateNotNullOrEmpty' should throw on null element of a collection argument or empty collection/dictionary" { - { NotNullOrEmptyFunc -Value @("string", $null, 2) } | Should -Throw - { NotNullOrEmptyFunc -Value @("string", "", 2) } | Should -Throw - { NotNullOrEmptyFunc -Value @() } | Should -Throw - { NotNullOrEmptyFunc -Value @{} } | Should -Throw + { NotNullOrEmptyFunc -Value @("string", $null, 2) } | Should -Throw -ErrorId "ParameterArgumentValidationError,NotNullOrEmptyFunc" + { NotNullOrEmptyFunc -Value @("string", "", 2) } | Should -Throw -ErrorId "ParameterArgumentValidationError,NotNullOrEmptyFunc" + { NotNullOrEmptyFunc -Value @() } | Should -Throw -ErrorId "ParameterArgumentValidationError,NotNullOrEmptyFunc" + { NotNullOrEmptyFunc -Value @{} } | Should -Throw -ErrorId "ParameterArgumentValidationError,NotNullOrEmptyFunc" } It "Mandatory parameter should throw on empty collection" { - { MandatoryFunc -ByteArray ([byte[]]@()) } | Should -Throw - { MandatoryFunc -ByteList ([System.Collections.Generic.List[byte]]@()) } | Should -Throw - { MandatoryFunc -ByteList ([System.Collections.ObjectModel.Collection[byte]]@()) } | Should -Throw + { MandatoryFunc -ByteArray ([byte[]]@()) } | Should -Throw -ErrorId "ParameterArgumentValidationErrorEmptyArrayNotAllowed,MandatoryFunc" + { MandatoryFunc -ByteList ([System.Collections.Generic.List[byte]]@()) } | Should -Throw -ErrorId "ParameterArgumentValidationErrorEmptyCollectionNotAllowed,MandatoryFunc" + { MandatoryFunc -ByteList ([System.Collections.ObjectModel.Collection[byte]]@()) } | Should -Throw -ErrorId "ParameterArgumentValidationErrorEmptyCollectionNotAllowed,MandatoryFunc" } } } diff --git a/test/powershell/engine/COM/COM.Basic.Tests.ps1 b/test/powershell/engine/COM/COM.Basic.Tests.ps1 index 3d35f74f966..83dab225651 100644 --- a/test/powershell/engine/COM/COM.Basic.Tests.ps1 +++ b/test/powershell/engine/COM/COM.Basic.Tests.ps1 @@ -45,7 +45,7 @@ try { ## $element should be the first drive from the enumeration. It shouldn't be the same as $drives, ## but it should be the same as '$drives.Item($element.DriveLetter)' $element = $drives | Select-Object -First 1 - [System.Object]::ReferenceEquals($element, $drives) | Should -Be $false + [System.Object]::ReferenceEquals($element, $drives) | Should -BeFalse $element | Should -Be $drives.Item($element.DriveLetter) } } diff --git a/test/powershell/engine/ETS/Adapter.Tests.ps1 b/test/powershell/engine/ETS/Adapter.Tests.ps1 index b7cc7c33535..c8a95514269 100644 --- a/test/powershell/engine/ETS/Adapter.Tests.ps1 +++ b/test/powershell/engine/ETS/Adapter.Tests.ps1 @@ -30,8 +30,8 @@ Describe "Adapter Tests" -tags "CI" { $col = $pso.psobject.Properties.Match("*") $prop = $col.psobject.Members["Item"] $prop | Should -Not -BeNullOrEmpty - $prop.IsGettable | Should -Be $true - $prop.IsSettable | Should -Be $false + $prop.IsGettable | Should -BeTrue + $prop.IsSettable | Should -BeFalse $prop.TypeNameOfValue | Should -Be "System.Management.Automation.PSPropertyInfo" $prop.Invoke("ProcessName").Value | Should -Be $processName } @@ -59,8 +59,8 @@ Describe "Adapter Tests" -tags "CI" { It "Access misc properties via MemberSet adapter" { $prop = $psmemberset.psobject.Properties["NoteName"] $prop | Should -Not -BeNullOrEmpty - $prop.IsGettable | Should -Be $true - $prop.IsSettable | Should -Be $true + $prop.IsGettable | Should -BeTrue + $prop.IsSettable | Should -BeTrue $prop.TypeNameOfValue | Should -Be "System.Int32" } diff --git a/test/powershell/engine/Help/HelpSystem.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.Tests.ps1 index cb569a17437..ed0bb72ab43 100644 --- a/test/powershell/engine/Help/HelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.Tests.ps1 @@ -179,7 +179,7 @@ Describe "Validate that Get-Help returns provider-specific help" -Tags @('CI', ' # System.Management.Automation.ProviderContext.GetProviderSpecificHelpInfo ignores extra whitespace, line breaks and # comments when loading help XML, but Select-Xml can not; use BeLikeExactly operator to omit trailing line breaks: - $helpXmlNode.description.para -clike "$expected*" | Should -Be $true + $helpXmlNode.description.para -clike "$expected*" | Should -BeTrue } } } diff --git a/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 b/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 index e3ed75bb595..c7df94a7236 100644 --- a/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/UpdatableHelpSystem.Tests.ps1 @@ -160,7 +160,7 @@ function ValidateInstalledHelpContent foreach ($fileName in $expectedHelpFiles) { - $helpFilesInstalled -contains $fileName | Should -Be $true + $helpFilesInstalled -contains $fileName | Should -BeTrue } } diff --git a/test/powershell/engine/Job/Jobs.Tests.ps1 b/test/powershell/engine/Job/Jobs.Tests.ps1 index afd25a320a0..e2903a2b483 100644 --- a/test/powershell/engine/Job/Jobs.Tests.ps1 +++ b/test/powershell/engine/Job/Jobs.Tests.ps1 @@ -74,7 +74,7 @@ Describe 'Basic Job Tests' -Tags 'CI' { $nativeJob = Start-job { pwsh -c 1+1 } $nativeJob | Wait-Job $nativeJob.State | Should -BeExactly "Completed" - $nativeJob.HasMoreData | Should -Be $true + $nativeJob.HasMoreData | Should -BeTrue Receive-Job $nativeJob | Should -BeExactly 2 Remove-Job $nativeJob { Get-Job $nativeJob -ErrorAction Stop } | ShouldBeErrorId "JobWithSpecifiedNameNotFound,Microsoft.PowerShell.Commands.GetJobCommand" diff --git a/test/powershell/engine/Module/ModulePath.Tests.ps1 b/test/powershell/engine/Module/ModulePath.Tests.ps1 index a2247bcd3ca..844ac97a7ef 100644 --- a/test/powershell/engine/Module/ModulePath.Tests.ps1 +++ b/test/powershell/engine/Module/ModulePath.Tests.ps1 @@ -90,8 +90,8 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { $paths = $newModulePath -split [System.IO.Path]::PathSeparator $paths.Count | Should -Be 5 - $paths -contains $fakePSHomeModuleDir | Should -Be $true - $paths -contains $customeModules | Should -Be $true + $paths -contains $fakePSHomeModuleDir | Should -BeTrue + $paths -contains $customeModules | Should -BeTrue } } diff --git a/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 b/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 index d5705d30ebd..9b86849d004 100644 --- a/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 +++ b/test/powershell/engine/Module/SubmodulePathInManifest.Tests.ps1 @@ -43,7 +43,7 @@ Describe "Tests for paths of submodules in module manifest" -tags "CI" { New-ModuleManifest $moduleFilePath -NestedModules @($SubModulePath) Import-Module $moduleFilePath - (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -Be $true + (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -BeTrue } It "Test if RootModule path is " -TestCases $testCases { @@ -51,6 +51,6 @@ Describe "Tests for paths of submodules in module manifest" -tags "CI" { New-ModuleManifest $moduleFilePath -RootModule $SubModulePath Import-Module $moduleFilePath - (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -Be $true + (Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -BeTrue } } diff --git a/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 b/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 index 5c347fd46da..14e4d07bb67 100644 --- a/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 +++ b/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 @@ -18,7 +18,7 @@ Describe "Test-ModuleManifest tests" -tags "CI" { New-ModuleManifest -NestedModules $fileList -RootModule foo\bar.psm1 -RequiredAssemblies $fileList -Path $testModulePath -TypesToProcess $fileList -FormatsToProcess $fileList -ScriptsToProcess $fileList -FileList $fileList -ModuleList $fileList - Test-Path $testModulePath | Should -Be $true + Test-Path $testModulePath | Should -BeTrue # use -ErrorAction Stop to cause test to fail if Test-ModuleManifest writes to error stream Test-ModuleManifest -Path $testModulePath -ErrorAction Stop | Should -BeOfType System.Management.Automation.PSModuleInfo diff --git a/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 b/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 index e2a3e49ff05..f4f07885274 100644 --- a/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/BooleanParameterDCR.Tests.ps1 @@ -45,10 +45,10 @@ Describe "BooleanParameterDCR Tests" -tags "CI" { It "Test that a nullable boolean is accepted for a boolean parameter." { [System.Nullable[System.Int32]] $nullBoolVar = $false $result = ParserTestBoolCmdlet2 $nullBoolVar - $result | should -Be $false + $result | should -BeFalse $result = ParserTestBoolCmdlet2 -First:$nullBoolVar - $result | should -Be $false + $result | should -BeFalse $result = ParserTestBoolCmdlet2 -First $nullBoolVar - $result | should -Be $false + $result | should -BeFalse } } diff --git a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 index bd156e6c2c5..6f660e89151 100644 --- a/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/ParameterBinding.Tests.ps1 @@ -116,7 +116,7 @@ Describe "Parameter Binding Tests" -Tags "CI" { } $result = test-singleswitchparameter - $result | Should -Be $false + $result | Should -BeFalse } It "Verify that a bool parameter returns proper value" { @@ -132,10 +132,10 @@ Describe "Parameter Binding Tests" -Tags "CI" { } $result1 = test-singleboolparameter - $result1 | Should -Be $false + $result1 | Should -BeFalse $result2 = test-singleboolparameter -Parameter1:1 - $result2 | Should -Be $true + $result2 | Should -BeTrue } It "Should throw a exception when passing a string that can't be parsed by Int" { diff --git a/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 b/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 index f230301be4a..4ff3796b9c9 100644 --- a/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 +++ b/test/powershell/engine/ParameterBinding/StaticParameterBinder.Tests.ps1 @@ -89,8 +89,8 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 0 ValidateScript = { param ($result) - $result.BoundParameters.Name.ConstantValue | Should -Be $true - $result.BoundParameters.Recurse.ConstantValue | Should -Be $true + $result.BoundParameters.Name.ConstantValue | Should -BeTrue + $result.BoundParameters.Recurse.ConstantValue | Should -BeTrue $result.BoundParameters.Path.ConstantValue | Should -Be 'abc' } }, @@ -101,7 +101,7 @@ Describe "StaticParameterBinder tests" -Tags "CI" { ExceptionCount = 1 ValidateScript = { param ($result) - $result.BoundParameters.Name.ConstantValue | Should -Be $true + $result.BoundParameters.Name.ConstantValue | Should -BeTrue $result.BindingExceptions.f.CommandElement.Extent.Text | Should -Be '-f' $result.BindingExceptions.f.BindingException.ErrorId | Should -Be 'AmbiguousParameter' } diff --git a/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 b/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 index 82d739de28e..1b81b1d3fdf 100644 --- a/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 +++ b/test/powershell/engine/Remoting/InvokeCommandRemoteDebug.Tests.ps1 @@ -207,7 +207,7 @@ Describe "Invoke-Command remote debugging tests" -Tags 'Feature' { It "Verifies the debugger 'CancelDebuggerProcessing' API method" { $rs.Debugger.CancelDebuggerProcessing() - $testDebugger.RunspaceDebugProcessCancelled | Should -Be $true + $testDebugger.RunspaceDebugProcessCancelled | Should -BeTrue } It "Verifies that 'Invoke-Command -RemoteDebug' running in a runspace without PSHost is ignored" { diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 index d156e9ee40d..bad76d962f6 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 @@ -82,7 +82,7 @@ Describe "JEA session Get-Help test" -Tag @("CI", 'RequireAdminOnWindows') { # Invoke the script block in a different PowerShell instance so that when TestDrive tries to delete $RoleCapDirectory, # the transcription has finished and the files are not locked. $helpContent = [powershell]::Create().AddScript($scriptBlock).Invoke() - $helpContent | Should -Not -Be $null + $helpContent | Should -Not -BeNullOrEmpty } finally { diff --git a/test/powershell/engine/Remoting/SessionOption.Tests.ps1 b/test/powershell/engine/Remoting/SessionOption.Tests.ps1 index 1a7763a94a8..5333abbc72f 100644 --- a/test/powershell/engine/Remoting/SessionOption.Tests.ps1 +++ b/test/powershell/engine/Remoting/SessionOption.Tests.ps1 @@ -14,11 +14,11 @@ try { } It "The SessionOption type has the proper properties when created with the default constructor" { $result = [Microsoft.WSMan.Management.SessionOption]::new() - $result.SkipCACheck | should -Be $False - $result.SkipCNCheck | should -Be $False - $result.SkipRevocationCheck | should -Be $False - $result.UseEncryption | should -Be $True - $result.UseUtf16 | should -Be $False + $result.SkipCACheck | should -BeFalse + $result.SkipCNCheck | should -BeFalse + $result.SkipRevocationCheck | should -BeFalse + $result.UseEncryption | should -BeTrue + $result.UseUtf16 | should -BeFalse $result.ProxyAuthentication | should -Be 0 $result.SPNPort | should -Be 0 $result.OperationTimeout | should -Be 0 @@ -38,11 +38,11 @@ try { $result.ProxyAccessType = "ProxyAutoDetect" $result.ProxyCredential = [System.Net.NetworkCredential]::new("user","pass") - $result.SkipCACheck | should -Be $true - $result.SkipCNCheck | should -Be $true - $result.SkipRevocationCheck | should -Be $true - $result.UseEncryption | should -Be $False - $result.UseUtf16 | should -Be $True + $result.SkipCACheck | should -BeTrue + $result.SkipCNCheck | should -BeTrue + $result.SkipRevocationCheck | should -BeTrue + $result.UseEncryption | should -BeFalse + $result.UseUtf16 | should -BeTrue $result.ProxyAuthentication | should -Be "Negotiate" $result.SPNPort | should -Be 10 $result.OperationTimeout | should -Be 10 From 0ac031fa785f115dcbf612f60b6e19a133949ab5 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Thu, 8 Mar 2018 11:23:38 -0800 Subject: [PATCH 3/7] [Feature] Tests correction in engine. --- .../powershell/engine/Api/GetNewClosure.Tests.ps1 | 4 ++-- .../engine/Api/InitialSessionState.Tests.ps1 | 11 +---------- .../powershell/engine/Api/TypeInference.Tests.ps1 | 2 +- .../engine/Basic/SemanticVersion.Tests.ps1 | 2 +- .../engine/Remoting/RoleCapabilityFiles.Tests.ps1 | 15 +-------------- 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/test/powershell/engine/Api/GetNewClosure.Tests.ps1 b/test/powershell/engine/Api/GetNewClosure.Tests.ps1 index c637fe806c5..44c6d452fdf 100644 --- a/test/powershell/engine/Api/GetNewClosure.Tests.ps1 +++ b/test/powershell/engine/Api/GetNewClosure.Tests.ps1 @@ -32,13 +32,13 @@ Describe "ScriptBlock.GetNewClosure()" -tags "CI" { } It "Parameter attributes should not get evaluated again in GetNewClosure - SimpleFunction" { - SimpleFunction_GetNewClosure | Should -Be "OK" + SimpleFunction_GetNewClosure | Should -BeExactly "OK" } It "Parameter attributes should not get evaluated again in GetNewClosure - ScriptCmdlet" { $result = ScriptCmdlet_GetNewClosure $result.Count | Should -Be 2 $result[0] | Should -Be 4 - $result[1] | Should -Be "" + $result[1] | Should -BeNullOrEmpty } } diff --git a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 index 2602820a615..d72785d8738 100644 --- a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 +++ b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 @@ -115,16 +115,7 @@ Describe "TypeTable duplicate types in reused runspace InitialSessionState TypeT It "Verifies that shared TypeTable is not allowed in ISS" { # Process TypeTable types from ISS. - $errorId = "" - try - { - $rs.Open() - throw "No Exception!" - } - catch - { - $_.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should -Be "ErrorsUpdatingTypes" - } + { $rs.Open() } | Should -Throw -ErrorId "RuntimeException" } } } diff --git a/test/powershell/engine/Api/TypeInference.Tests.ps1 b/test/powershell/engine/Api/TypeInference.Tests.ps1 index 9fd63d4999d..a11a2c61458 100644 --- a/test/powershell/engine/Api/TypeInference.Tests.ps1 +++ b/test/powershell/engine/Api/TypeInference.Tests.ps1 @@ -93,7 +93,7 @@ Describe "Type inference Tests" -tags "CI" { $res = [AstTypeInference]::InferTypeOf( $ast ) $res.Count | Should -Be 1 - $res.Name | Should -Be System.DateTime + $res.Name | Should -BeExactly 'System.DateTime' } It "Infers type from ScriptblockExpresssion" { diff --git a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 index aaa87b2d0ee..fbaceaa1674 100644 --- a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 +++ b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 @@ -72,7 +72,7 @@ Describe "SemanticVersion api tests" -Tags 'CI' { It "Can covert to 'Version' type" { $v1 = [SemanticVersion]::new(3, 2, 1, "prerelease", "meta") $v2 = [Version]$v1 - $v2.GetType() | Should -Be "Version" + $v2.GetType() | Should -BeExactly "Version" $v2.PSobject.TypeNames[0] | Should -Be "System.Version#IncludeLabel" $v2.Major | Should -Be 3 $v2.Minor | Should -Be 2 diff --git a/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 b/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 index 531209a361d..179f892baef 100644 --- a/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 +++ b/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 @@ -93,20 +93,7 @@ Describe "Remote session configuration RoleDefintion RoleCapabilityFiles key tes [powershell] $ps = [powershell]::Create($iss) $null = $ps.AddCommand('Get-Service') - $exceptionTypeName = "" - try - { - $ps.Invoke() - throw 'No Exception!' - } - catch - { - if ($null -ne $_.Exception.InnerException) - { - $exceptionTypeName = $_.Exception.InnerException.GetType().FullName - } - $exceptionTypeName | Should -Be 'System.Management.Automation.CommandNotFoundException' - } + { $ps.Invoke() } | Should -Throw -ErrorId 'System.Management.Automation.CommandNotFoundException' $ps.Dispose() } From 7babe8c8779c677b66e6934d7f47e2e565cc7dd2 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Thu, 8 Mar 2018 13:33:02 -0800 Subject: [PATCH 4/7] [Feature] Test correction in engine. --- test/powershell/engine/Api/InitialSessionState.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 index d72785d8738..886af18654f 100644 --- a/test/powershell/engine/Api/InitialSessionState.Tests.ps1 +++ b/test/powershell/engine/Api/InitialSessionState.Tests.ps1 @@ -115,7 +115,8 @@ Describe "TypeTable duplicate types in reused runspace InitialSessionState TypeT It "Verifies that shared TypeTable is not allowed in ISS" { # Process TypeTable types from ISS. - { $rs.Open() } | Should -Throw -ErrorId "RuntimeException" + $e = { $rs.Open() } | Should -Throw -ErrorId "RuntimeException" -PassThru + $e.Exception.InnerException.ErrorRecord.FullyQualifiedErrorId | Should -BeExactly "ErrorsUpdatingTypes" } } } From f58a0c8405f7853868853afe2b342cc091b42a7e Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Thu, 8 Mar 2018 14:18:58 -0800 Subject: [PATCH 5/7] [Feature] Test correction in engine. --- test/powershell/engine/Basic/SemanticVersion.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 index fbaceaa1674..0d5f3d3fbd6 100644 --- a/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 +++ b/test/powershell/engine/Basic/SemanticVersion.Tests.ps1 @@ -72,7 +72,7 @@ Describe "SemanticVersion api tests" -Tags 'CI' { It "Can covert to 'Version' type" { $v1 = [SemanticVersion]::new(3, 2, 1, "prerelease", "meta") $v2 = [Version]$v1 - $v2.GetType() | Should -BeExactly "Version" + $v2.GetType() | Should -BeExactly "version" $v2.PSobject.TypeNames[0] | Should -Be "System.Version#IncludeLabel" $v2.Major | Should -Be 3 $v2.Minor | Should -Be 2 From 5092da704db2ca053bdf44b6de6805e9df8e6eaa Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Thu, 8 Mar 2018 15:40:25 -0800 Subject: [PATCH 6/7] [Feature] Test correction in engine. --- test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 b/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 index 179f892baef..ddc1287ae67 100644 --- a/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 +++ b/test/powershell/engine/Remoting/RoleCapabilityFiles.Tests.ps1 @@ -93,7 +93,7 @@ Describe "Remote session configuration RoleDefintion RoleCapabilityFiles key tes [powershell] $ps = [powershell]::Create($iss) $null = $ps.AddCommand('Get-Service') - { $ps.Invoke() } | Should -Throw -ErrorId 'System.Management.Automation.CommandNotFoundException' + { $ps.Invoke() } | Should -Throw -ErrorId 'CommandNotFoundException' $ps.Dispose() } From b9548d880769d44f7885b5932dcaf197850c36fc Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Fri, 9 Mar 2018 10:05:42 -0800 Subject: [PATCH 7/7] [Feature]