Skip to content

Instantly share code, notes, and snippets.

@adbertram
Last active July 26, 2017 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adbertram/4abd63f72569bd7ad5987fb2f72e4ee6 to your computer and use it in GitHub Desktop.
Save adbertram/4abd63f72569bd7ad5987fb2f72e4ee6 to your computer and use it in GitHub Desktop.
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