mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 13:23:29 +00:00
added - before gen of file
This commit is contained in:
41
Examples/TestRestAPI/TestAPIReadXls.ps1
Normal file
41
Examples/TestRestAPI/TestAPIReadXls.ps1
Normal file
@@ -0,0 +1,41 @@
|
||||
function Test-APIReadXls {
|
||||
param(
|
||||
[parameter(Mandatory)]
|
||||
$XlFilename,
|
||||
$WorksheetName = 'Sheet1'
|
||||
)
|
||||
|
||||
$records = Import-Excel $XlFilename
|
||||
|
||||
$params = @{}
|
||||
|
||||
$blocks = $(foreach ($record in $records) {
|
||||
foreach ($propertyName in $record.psobject.properties.name) {
|
||||
if ($propertyName -notmatch 'ExpectedResult|QueryString') {
|
||||
$params.$propertyName = $record.$propertyName
|
||||
}
|
||||
}
|
||||
|
||||
if ($record.QueryString) {
|
||||
$params.Uri += "?{0}" -f $record.QueryString
|
||||
}
|
||||
|
||||
@"
|
||||
|
||||
it "Should have the expected result '$($record.ExpectedResult)'" {
|
||||
`$target = '$($params | ConvertTo-Json -compress)' | ConvertFrom-Json
|
||||
`$target.psobject.Properties.name | % {`$p=@{}} {`$p.`$_=`$(`$target.`$_)}
|
||||
Invoke-RestMethod @p | Should Be '$($record.ExpectedResult)'
|
||||
}
|
||||
|
||||
"@
|
||||
})
|
||||
|
||||
@"
|
||||
Describe "Tests from $($XlFilename) in $($WorksheetName)" {
|
||||
$($blocks)
|
||||
}
|
||||
"@
|
||||
}
|
||||
|
||||
Test-APIReadXls .\testlist.xlsx
|
||||
BIN
Examples/TestRestAPI/testlist.xlsx
Normal file
BIN
Examples/TestRestAPI/testlist.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user