diff --git a/samples/client/petstore/powershell-experimental/Test1.ps1 b/samples/client/petstore/powershell-experimental/Test1.ps1 index b7e92caf90f2..268665d81b1f 100644 --- a/samples/client/petstore/powershell-experimental/Test1.ps1 +++ b/samples/client/petstore/powershell-experimental/Test1.ps1 @@ -17,6 +17,17 @@ $Id = 38369 #$result = Update-PSPetWithForm try { + $pet = Initialize-PSPet -Id $Id -Name 'foo' -Category ( + Initialize-PSCategory -Id $Id -Name 'bar' + ) -PhotoUrls @( + 'http://example.com/foo', + 'http://example.com/bar' + ) -Tags ( + Initialize-PSTag -Id 3 -Name 'baz' + ) -Status Available + + #Write-Host $pet + $Result = Add-PSPet -Pet $pet Set-PSConfigurationApiKey -Id "api_key" -ApiKey "zzZZZZZZZZZZZZZ" $result = Get-PSPetById -petId $Id -Verbose #-testHeader "testing only" -testQuery "testing something here" } catch { @@ -29,17 +40,22 @@ try { #$result | Select-Object -Property "photoUrls" | ConvertTo-Json | Write-Host #Write-Host "result =" + $result.photoUrls -#$pet = Initialize-Pet -Id 10129 -Name 'foo' -Category ( -# Initialize-Category -Id 2 -Name 'bar' -#) -PhotoUrls @( -# 'http://example.com/foo', -# 'http://example.com/bar' -#) -Tags ( -# Initialize-Tag -Id 3 -Name 'baz' -#) -Status Available -# + +$pet2 = Initialize-PSPet -Id 20129 -Name '2foo' -Category ( + Initialize-PSCategory -Id 20129 -Name '2bar' +) -PhotoUrls @( + 'http://example.com/2foo', + 'http://example.com/2bar' +) -Tags ( + Initialize-PSTag -Id 3 -Name 'baz' +) -Status Available + #Write-Host $pet -#$Result = Invoke-PetApiAddPet -Body $pet +$Result = Add-PSPet -Pet $pet2 + +$Result = Find-PSPetsByTags 'baz' +Write-Host $Result.GetType().Name +Write-Host $Result #$Result = Invoke-PetApiUpdatePetWithForm -petId $Id -Name "PowerShell Update" -Status "Pending" diff --git a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 index 0cff3e155a26..1c678b649f0a 100644 --- a/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 +++ b/samples/client/petstore/powershell-experimental/tests/Petstore.Tests.ps1 @@ -26,6 +26,8 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $Result."id" | Should Be 38369 $Result."name" | Should Be "PowerShell" $Result."status" | Should Be "Available" + $Result."category"."id" | Should Be $Id + $Result."category"."name" | Should Be 'PSCategory' $Result.GetType().fullname | Should Be "System.Management.Automation.PSCustomObject" @@ -65,6 +67,51 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' { $Result = Remove-Pet -petId $Id } + + It 'Find pets test' { + + # add 1st pet + $pet = Initialize-PSPet -Id 10129 -Name 'foo' -Category ( + Initialize-PSCategory -Id 20129 -Name 'bar' + ) -PhotoUrls @( + 'http://example.com/foo', + 'http://example.com/bar' + ) -Tags ( + Initialize-PSTag -Id 10129 -Name 'bazbaz' + ) -Status Available + + $Result = Add-PSPet -Pet $pet + + # add 2nd pet + $pet2 = Initialize-PSPet -Id 20129 -Name '2foo' -Category ( + Initialize-PSCategory -Id 20129 -Name '2bar' + ) -PhotoUrls @( + 'http://example.com/2foo', + 'http://example.com/2bar' + ) -Tags ( + Initialize-PSTag -Id 10129 -Name 'bazbaz' + ) -Status Available + + $Result = Add-PSPet $pet2 + + # test find pets by tags + $Results = Find-PSPetsByTags 'bazbaz' + $Results.GetType().FullName| Should Be "System.Object[]" + $Results.Count | Should Be 2 + + if ($Results[0]."id" -gt 10129) { + $Results[0]."id" | Should Be 20129 + } else { + $Results[0]."id" | Should Be 10129 + } + + if ($Results[1]."id" -gt 10129) { + $Results[1]."id" | Should Be 20129 + } else { + $Results[1]."id" | Should Be 10129 + } + + } } Context 'Configuration' {