Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active June 8, 2024 22:07
Show Gist options
  • Save techthoughts2/acd7dd2d749240c4be596c37b1c03446 to your computer and use it in GitHub Desktop.
Save techthoughts2/acd7dd2d749240c4be596c37b1c03446 to your computer and use it in GitHub Desktop.
$script:mockCalled = 0
$mockInvoke = {
$script:mockCalled++
if ($script:mockCalled -eq 1) {
return $false
}
elseif ($script:mockCalled -eq 2) {
return $true
}
}
Mock -CommandName Get-TableRowInfo -MockWith $mockInvoke
# alternative mock iteration
$script:mockCalled = 0
Mock -CommandName Convert-MediaToBase64 -MockWith {
$script:mockCalled++
if ($script:mockCalled -eq 1) {
return 'base64-encoded-image'
}
elseif ($script:mockCalled -eq 2) {
throw 'Error'
}
} #endMock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment