Reputation: 11
I have a problem. I want to test my PowerShell script by Pester. This is my function to test:
function Remove-Diacritics {
param (
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[String]$string
)
$cleanText = $string -replace "[\p{Mn}]", ""
return $cleanText
#$cleanText = ($string.Normalize([Text.NormalizationForm]::FormD)) -creplace "\p{Mn}"
#return $cleanText
}
}
Pester test:
Describe "Remove-Diacritics" {
BeforeAll {
Import-Module D:\scripts\test\patching_common.psm1
}
Context "When removing diacritics from a string" {
It "should remove diacritics and return a clean string" {
$text = "Café"
$expectedOutput = "Cafe"
$output = Remove-Diacritics -string $text
$output | Should -Be $expectedOutput
}
}
}
As a result I am getting this error:
Expected: 'Cafe'
But was: 'CafA©'
But when I run the script with function in PS terminal it returns 'Cafe'
Can it be because of some encoding?
Upvotes: 1
Views: 74