mercredi 17 août 2016

Pester does not call the mocked function - what am i doing wrong?

I want to mock a .net assembly function. I tried to wrap the .net function in a powershell function, but Pester still calls the original implementation of the function---how to fix? This is my test:

    Describe "something" {
$result =(.$SomeScript)   <--- get modules loaded in memory 
Context "Happy Path" {
    it "Call mocked method 1x" {
        Mock  MyFunc{ "" }
        $result =$result =(& $SomeScript)

In SomeScript , i have a implementation like this :

function MyFunc($param1, $param2)
{
return [namespace.class]::function($param1, $param2)
} 

Aucun commentaire:

Enregistrer un commentaire