/Tests/Get-EscapedString.Tests.ps1

https://github.com/pspete/psPAS · Powershell · 52 lines · 26 code · 22 blank · 4 comment · 1 complexity · 5d0a356bc51e7f420660c57e70bb95da MD5 · raw file

  1. Describe $($PSCommandPath -Replace ".Tests.ps1") {
  2. BeforeAll {
  3. #Get Current Directory
  4. $Here = Split-Path -Parent $PSCommandPath
  5. #Assume ModuleName from Repository Root folder
  6. $ModuleName = Split-Path (Split-Path $Here -Parent) -Leaf
  7. #Resolve Path to Module Directory
  8. $ModulePath = Resolve-Path "$Here\..\$ModuleName"
  9. #Define Path to Module Manifest
  10. $ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1"
  11. if ( -not (Get-Module -Name $ModuleName -All)) {
  12. Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop
  13. }
  14. $Script:RequestBody = $null
  15. $Script:BaseURI = "https://SomeURL/SomeApp"
  16. $Script:ExternalVersion = "0.0"
  17. $Script:WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
  18. }
  19. AfterAll {
  20. $Script:RequestBody = $null
  21. }
  22. InModuleScope $(Split-Path (Split-Path (Split-Path -Parent $PSCommandPath) -Parent) -Leaf ) {
  23. It 'outputs a string' {
  24. "+ & %" | Get-EscapedString | Should -BeOfType System.String
  25. }
  26. It 'outputs an escaped string' {
  27. "+ & %" | Get-EscapedString | Should -BeExactly "%2B%20%26%20%25"
  28. }
  29. }
  30. }