diff --git a/test/powershell/Environment-Variables.Tests.ps1 b/test/powershell/Environment-Variables.Tests.ps1 index f8a62e0cf..01ce011f4 100644 --- a/test/powershell/Environment-Variables.Tests.ps1 +++ b/test/powershell/Environment-Variables.Tests.ps1 @@ -24,12 +24,13 @@ if ($isWindows) { $expected = "\Users\" + $ENV:USERNAME + $ENV:HOMEPATH | Should Be $expected } else { $expected = /bin/bash -c "cd ~ && pwd" - } $ENV:HOME | Should Be $expected + } } It "Should be able to set the environment variables" { diff --git a/test/powershell/Get-FileHash.Tests.ps1 b/test/powershell/Get-FileHash.Tests.ps1 index f4d816c1d..11011e3ae 100644 --- a/test/powershell/Get-FileHash.Tests.ps1 +++ b/test/powershell/Get-FileHash.Tests.ps1 @@ -1,12 +1,12 @@ Describe "Get-FileHash" { - New-Variable testDocument -Value (Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath testablescript.ps1) -Scope Global -Force - # The MACTripleDES and RIPEMD160 algorithms are unsupported at the moment + New-Variable testDocument -Value (Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath testablescript.ps1) -Scope Global -Force + # The MACTripleDES and RIPEMD160 algorithms are unsupported on Linux $algorithms = @{"SHA1" ="01B865D143E07ECC875AB0EFC0A4429387FD0CF7"; "SHA256" = "4A6DA9F1C0827143BB19FC4B0F2A8057BC1DF55F6D1F62FA3B917BA458E8F570"; "SHA384" = "656215B6A07011E625206F43E57873F49AD7B36DFCABB70F6CDCE2303D7A603E55D052774D26F339A6D80A264340CB8C"; "SHA512" = "C688C33027D89ACAC920545471C8053D8F64A54E21D0415F1E03766DDCDA215420E74FAFD1DC399864C6B6B5723A3358BD337339906797A39090B02229BF31FE"; "MD5" = "7B09811D1631C9FD46B39D1D35522F0A"; - } + } Context "Cmdlet result tests" { It "Should default to correct hash algorithm" { @@ -28,7 +28,7 @@ It "Should list the path of the file under test" { $result = Get-FileHash $testDocument - $result.Path | Should Match (Join-Path assets -ChildPath testablescript.ps1) + $result.Path | Should Be $testDocument } } diff --git a/test/powershell/Get-Item.Tests.ps1 b/test/powershell/Get-Item.Tests.ps1 index e4aa7fd8f..afd2d6bc5 100644 --- a/test/powershell/Get-Item.Tests.ps1 +++ b/test/powershell/Get-Item.Tests.ps1 @@ -8,7 +8,7 @@ Describe "Get-Item" { It "Should return the name of the current working directory when a dot is used" { (Get-Item $here).GetType().BaseType | Should Be 'System.IO.FileSystemInfo' - (Get-Item $here).Name | Should Be 'powershell' + (Get-Item $here).Name | Should Be (Split-Path $here -Leaf) } It "Should return the proper Name and BaseType for directory objects vs file system objects" { diff --git a/test/powershell/Get-RunspaceDebug.Tests.ps1 b/test/powershell/Get-RunspaceDebug.Tests.ps1 index 7c66ed736..d2d1578f6 100644 --- a/test/powershell/Get-RunspaceDebug.Tests.ps1 +++ b/test/powershell/Get-RunspaceDebug.Tests.ps1 @@ -3,7 +3,8 @@ Describe "Get-RunspaceDebug" { Context "Check return types of RunspaceDebug" { It "Should return Microsoft.Powershell.Commands.PSRunspaceDebug as the return type" { - (Get-RunspaceDebug).GetType() | Should Be Microsoft.Powershell.Commands.PSRunspaceDebug + $rs = Get-RunspaceDebug + $rs[0].GetType().Name | Should Be PSRunspaceDebug } } } diff --git a/test/powershell/Measure-Object.Tests.ps1 b/test/powershell/Measure-Object.Tests.ps1 index 602a5af5e..ac1b471a3 100644 --- a/test/powershell/Measure-Object.Tests.ps1 +++ b/test/powershell/Measure-Object.Tests.ps1 @@ -126,7 +126,7 @@ } Context "String tests" { - $nl = [Environment]::NewLine + $nl = [Environment]::NewLine $testString = "HAD I the heavens’ embroidered cloths,$nl Enwrought with golden and silver light,$nl The blue and the dim and the dark cloths$nl Of night and light and the half light,$nl I would spread the cloths under your feet:$nl But I, being poor, have only my dreams;$nl I have spread my dreams under your feet;$nl Tread softly because you tread on my dreams." @@ -145,7 +145,7 @@ } It "Should be able to count the number of lines in a string" { - $expectedLength = $testString.Split($nl).length + $expectedLength = $testString.Split($nl, [System.StringSplitOptions]::RemoveEmptyEntries).length $actualLength = $testString | Measure-Object -Line $actualLength.Lines | Should Be $expectedLength diff --git a/test/powershell/Select-String.Tests.ps1 b/test/powershell/Select-String.Tests.ps1 index b7144b20d..a32a3cca2 100644 --- a/test/powershell/Select-String.Tests.ps1 +++ b/test/powershell/Select-String.Tests.ps1 @@ -157,7 +157,7 @@ $relativePath = Join-Path -Path $testDirectory -ChildPath ".." $relativePath = Join-Path -Path $relativePath -ChildPath ".." - $relativePath = Join-Path -Path $relativePath -ChildPath $testDirectory + $relativePath = Join-Path -Path $relativePath -ChildPath (Split-Path $testDirectory -NoQualifier) $relativePath = Join-Path -Path $relativePath -ChildPath testfile1.txt Select-String third $relativePath | Should Match $expected } diff --git a/test/powershell/Set-PSBreakpoint.Tests.ps1 b/test/powershell/Set-PSBreakpoint.Tests.ps1 index 18e492157..a4a957e35 100644 --- a/test/powershell/Set-PSBreakpoint.Tests.ps1 +++ b/test/powershell/Set-PSBreakpoint.Tests.ps1 @@ -8,25 +8,31 @@ Describe "Set-PSBreakpoint" { It "Should be able to set a psbreakpoint on a line" { $lineNumber = 1 - $(Set-PSBreakpoint -Line $lineNumber -Script $testScript).Line | Should Be $lineNumber + $brk = Set-PSBreakpoint -Line $lineNumber -Script $testScript + $brk.Line | Should Be $lineNumber + Remove-PSBreakPoint -Id $brk.Id } It "Should throw when a string is entered for a line number" { { $lineNumber = "one" - $(Set-PSBreakpoint -Line $lineNumber -Script $testScript).Line + Set-PSBreakpoint -Line $lineNumber -Script $testScript } | Should Throw } It "Should be able to set a psbreakpoint on a Command" { $command = "theCommand" - $(Set-PSBreakpoint -Command $command -Script $testScript).Command | Should Be $command + $brk = Set-PSBreakpoint -Command $command -Script $testScript + $brk.Command | Should Be $command + Remove-PSBreakPoint -Id $brk.Id } It "Should be able to set a psbreakpoint on a variable" { $var = "theVariable" - $(Set-PSBreakpoint -Command $var -Script $testScript).Command | Should Be $var + $brk = Set-PSBreakpoint -Command $var -Script $testScript + $brk.Command | Should Be $var + Remove-PSBreakPoint -Id $brk.Id } # clean up after ourselves diff --git a/test/powershell/Test-Common.ps1 b/test/powershell/Test-Common.ps1 index 2e968cbaf..a03a47eac 100644 --- a/test/powershell/Test-Common.ps1 +++ b/test/powershell/Test-Common.ps1 @@ -1,7 +1,7 @@ Function IsWindows { $pingCommand = Get-Command -CommandType Application ping - if ($pingCommand.Definition.IndexOf("\\") -ne -1) + if ($pingCommand.Definition.IndexOf("\") -ne -1) { return 1; } diff --git a/test/powershell/Wait-Event.Tests.ps1 b/test/powershell/Wait-Event.Tests.ps1 index 842ee47fd..c7cd185cf 100644 --- a/test/powershell/Wait-Event.Tests.ps1 +++ b/test/powershell/Wait-Event.Tests.ps1 @@ -8,7 +8,7 @@ Describe "Wait-Event" { # raised because it is fake Wait-Event -Timeout 1 -SourceIdentifier "FakeEvent" $stopwatch.Stop() - $stopwatch.ElapsedMilliseconds | Should BeGreaterThan 1000 + $stopwatch.ElapsedMilliseconds | Should BeGreaterThan 999 } } }