-
-
Save adbertram/4abd63f72569bd7ad5987fb2f72e4ee6 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
function Get-CacheOptions | |
{ | |
[CmdletBinding()] | |
[OutputType('bool')] | |
param( | |
[Parameter(Mandatory=$true)] | |
[System.Web.Services.Protocols.SoapHttpClientProtocol]$ssrsproxy, | |
[Parameter(Mandatory=$true)] | |
[string]$path | |
) | |
$cacheOptions = $null | |
$null = $ssrsproxy.GetCacheOptions($path,[ref]$cacheOptions) | |
if ($cacheOptions) { | |
$cacheOptions | |
} | |
} | |
describe 'Get-CacheOptions' { | |
$commandName = 'Get-CacheOptions' | |
$command = Get-Command -Name $commandName | |
context 'When some scenario happens where GetCacheOptions returns something' { | |
$testProxy = New-MockObject -Type 'System.Web.Services.Protocols.SoapHttpClientProtocol' | |
$testProxy | Add-Member -MemberType ScriptMethod -Name 'GetCacheOptions' -Force -Value { $true } | |
## Make these parameters to where you know GetCacheOptions is going to return something | |
$parameters = @{ | |
ssrsproxy = $testProxy | |
path = 'C:\path' | |
} | |
$result = & $commandName @parameters | |
it 'should return nothing' { | |
$result | should benullorEmpty | |
} | |
} | |
context 'When some scenario happens where GetCacheOptions does not return anything' { | |
$testProxy = New-MockObject -Type 'System.Web.Services.Protocols.SoapHttpClientProtocol' | |
$testProxy | Add-Member -MemberType ScriptMethod -Name 'GetCacheOptions' -Force -Value { $false } | |
## Make these parameters to where you know GetCacheOptions is not going to return something | |
$parameters = @{ | |
ssrsproxy = $testProxy | |
path = 'C:\path' | |
} | |
$result = & $commandName @parameters | |
it 'should return the expected number of objects' { | |
@($result).Count | should be 1 | |
} | |
it 'should return the same object type in OutputType()' { | |
$result | should beoftype $command.OutputType.Name | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment