Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I user a parameterFilter with a switch parameter when mocking in Pester?

Using Pester, I'm mocking an advanced function which takes, amongst other parameters, a switch. How do I create a -parameterFilter for the mock which includes the switch parameter?

I've tried:

-parameterFilter { $Domain -eq 'MyDomain' -and $Verbose -eq $true }

-parameterFilter { $Domain -eq 'MyDomain' -and $Verbose }

-parameterFilter { $Domain -eq 'MyDomain' -and $Verbose -eq 'True' }

to no avail.

like image 467
Simon Avatar asked Nov 11 '13 19:11

Simon


1 Answers

Try this:

-parameterFilter { $Domain -eq 'MyDomain' -and $Verbose.IsPresent}
like image 172
Constantin Daniil Avatar answered Oct 04 '22 20:10

Constantin Daniil