Last active
March 22, 2016 19:44
-
-
Save brantb/77013b44e791ce762f24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Describe 'Mocking Azure Powershell cmdlets' { | |
Mock New-AzureRmResource { Write-Host "Mock invoked" } | |
It 'Does not throw an exception' { | |
New-AzureRmResource -Properties @{} -ResourceId foo | |
} | |
} | |
<# | |
Without running Login-AzureRmAccount: | |
Describing Mocking Azure Powershell cmdlets | |
[-] Does not throw an exception 41ms | |
PSInvalidOperationException: Run Login-AzureRmAccount to login. | |
MethodInvocationException: Exception calling ".ctor" with "0" argument(s): "Run Login-AzureRmAccount to login." | |
CmdletInvocationException: Exception calling ".ctor" with "0" argument(s): "Run Login-AzureRmAccount to login." | |
ParameterBindingException: Cannot retrieve the dynamic parameters for the cmdlet. Exception calling ".ctor" with "0" argument(s): "Run Login-AzureRmAccount to login." | |
at <ScriptBlock>, C:\users\brant\Desktop\Pester.Tests.ps1: line 5 | |
After running Login-AzureRmAccount: | |
Describing Mocking Azure Powershell cmdlets | |
Mock invoked | |
[+] Does not throw an exception 43ms | |
Tests completed in 43ms | |
Passed: 1 Failed: 0 Skipped: 0 Pending: 0 Inconclusive: 0 | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment