I have a need to have a test case call a web service proxy and the results used in my pester script here is what I’m trying to do.
the function requires a proxy so that you can call methods. I want to verify that the method I call through the proxy is returning something or better yet returns a type of: SSRSProxy.ScheduleDefinition
My problem is every time I run the test I can’t seem to figure out the right means to formulate my Test case. so that it goes to the It block properly. What am I missing?
#---------function to be tested ---------------
function Get-CacheOptions
{
param(
[Parameter(Mandatory=$true)]
[object]$ssrsproxy,
[Parameter(Mandatory=$true)]
[string]$path
)
$cacheOptions = $null
$ssrsproxy.GetCacheOptions($path,[ref]$cacheOptions) | Out-Null
if($cacheOptions.Item -is [SSRSProxy.ScheduleDefinition])
{$cacheOptions}
else {
$cacheOptions = $null
}
}
#----------------- test case and pester code below ------------------------
#$ssrsproxy = New-WebServiceProxy -Uri 'http://ssrsdev/reportserver/reportservice2010.asmx' -UseDefaultCredential -namespace 'SSRSProxy' -class 'ReportService2010' -ErrorAction 0
Describe 'Get-CacheOptions' {
$testCases = @(
@{
ssrsproxy = (New-WebServiceProxy -Uri 'http://ssrs/reportserver/reportservice2010.asmx' -UseDefaultCredential -namespace 'SSRSProxy' -class 'ReportService2010' -ErrorAction 0);
path = '/Reports/DataSets/DocumentChanges'
}
@{
ssrsproxy = (New-WebServiceProxy -Uri 'http://ssrs/reportserver/reportservice2010.asmx' -UseDefaultCredential -namespace 'SSRSProxy' -class 'ReportService2010' -ErrorAction 0);
path = '/Reports/DataSets/ColorChanges'
}
)
Context 'running with arguments' {
It 'does something' -TestCases $testCases {
foreach($testcase in $testcases)
{
(get-CacheOptions -ssrsproxy $testcase.ssrsproxy -path $testcase.path).item | should exist
#(get-CacheOptions -ssrsproxy $testcase.ssrsproxy -path $testcase.path).item | should beoftype SSRSProxy.ScheduleDefinition
}
}
}
}