forked from markheath/funcs-todo-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.ps1
More file actions
37 lines (27 loc) · 1.34 KB
/
Test.ps1
File metadata and controls
37 lines (27 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$rootUrl = "http://localhost:7071"
$prefix = "table" # ef, memory, blob, table, cosmos
function Make-RestCall() {
-ContentType "application/json"
}
Write-Host "Testing with $prefix"
# add TODO item
$createModel = @{ TaskDescription="First task"}
$body = $createModel | ConvertTo-Json
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Body $body -Method Post -ContentType "application/json"
$createModel = @{ TaskDescription="Second task"}
$body = $createModel | ConvertTo-Json
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Body $body -Method Post -ContentType "application/json"
# get the TODO items
$items = Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Method Get
ForEach ($todo in $items) {
Write-Host "Updating $($todo.Id) - $($todo.TaskDescription)"
$updateModel = @{ IsCompleted=$true}
$body = $updateModel | ConvertTo-Json
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo/$($todo.id)" -Body $body -Method Put
Write-Host "Retrieving $($todo.Id) - $($todo.TaskDescription)"
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo/$($todo.id)" -Method Get
Write-Host "Deleting $($todo.Id) - $($todo.TaskDescription)"
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo/$($todo.id)" -Method Delete
}
Write-Host "Check they are all gone..."
Invoke-RestMethod -Uri "$rootUrl/api/$($prefix)todo" -Method Get