I have the following code in my Test:
It "Set mock partitions"{
Mock Get-Disk {
return [PSCustomObject]@{
SerialNumber = "SERIAL"
}
}
Mock Get-Partition {
param([PSCustomObject] $InputObject)
return @([PSCustomObject]@{
PartitionNumber = 1
},[PSCustomObject]@{
PartitionNumber = 2
})
}
Custom-Function
}
In my main script, i have the following function:
function Custom-Function(){
$Disk = Get-Disk
$Partition = Get-Partition -InputObject $Disk
}
When i run the test, i get the following error message:
The error happens on the line where
Get-Partition -InputObject $Disk
is called.
Is there something wrong with my mock-definition of the InputObject
parameter, or something else i am missing?