Reputation: 221
I have script that has the following code:
$var1 = [TESTType]::new($Var)
I would like to run a pester test that Mock [TESTType]::new($Var). Is This possible ?
Upvotes: 2
Views: 339
Reputation: 1690
One option is to use a wrapper function. You could for example do this:
function Get-TESTType {
param(
[Parameter()]$ContructorVar
)
return [TESTType]::new($ConstructorVar)
}
Then you can mock this function
It "Mocks the TESTType Class" {
Mock Get-TESTType {
@{
field1 = 'something'
field2 = 'something'
}
}
# Put your test here
}
Upvotes: 1