[Write-CUPesterTest] Erro when you use [System.XXXX] as return type in method
When you have a method in your class and in return value you put [System.String] or [System.Int32] (probably the others too) if you generate the tests pester it puts errors when you play them
Describing [Date]-[Methods]
[-] [Date] --> MethodTest($Message) : [System.String] - should return type [System.String]
Expected strings to be the same, but they were different.
Expected length: 13
Actual length: 6
Strings differ at index 1.
Expected: 'System.String'
But was: 'String'
83: ($Instance.MethodTest($Message)).GetType().Name | should be System.String
in the pester file you have
#Public Method
It '[Date] --> MethodTest($Message) : [System.String] - should return type [System.String]' {
# -- Arrange
[System.String]$Message = "test"
# -- Act
$Instance = [Date]::New()
# -- Assert
($Instance.MethodTest($Message)).GetType().Name | should be System.String
} #End It Block`
and my method is
[System.String] MethodTest ([System.String]$Message) {
return "Mon message est : $($Message)"
}
Actually, the return is a String type and not [System.String]
PS > ($date.MethodTest("test")).gettype()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
I think that the solution would be to add in the Write-CUPesterTest a transformation so that if it finds [System.XXXX] it transforms it into [XXXX] in pester test
Idea ! You can change in pester test $resultat.GetType().name by $resultat.GetType().fullname ;-)
With $resultat.GetType().fullname in pester test it seems good with [System.String] or [String] as return Type 👍
Salut @LaurentLienhard c'est quoi le statut de celui la? Je peux le merge?
je pense que Oui. Lors de mes derniers tests quand j'ai fait le PR cela corrigé bien le souci entre [system.XXX] et [XXX]