Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #358

Closed
wants to merge 5 commits into from
Closed

test #358

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions exercises/practice/rest-api/RestApi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Describe "RestApi test cases" {
$got = $api.Post("/iou", '{"lender": "Adam", "borrower": "Bob", "amount": 3.0}')
$want = @{
users = @(
@{name = "Adam" ; owes = @{}; owed_by = @{Bob = 3.0}; balance = 3.0}
@{name = "Adam" ; owes = @{}; owed_by = @{Bob = 3.0}; balance = 3.0}
@{name = "Bob" ; owes = @{Adam = 3.0 ; Chuck = 3.0}; owed_by = @{}; balance = -6.0}
)
}
Expand All @@ -96,7 +96,7 @@ Describe "RestApi test cases" {
It "iou -> lender has negative balance" {
$data = @{
users = @(
@{name = "Adam" ; owes = @{}; owed_by = @{}; balance = 0.0}
@{name = "Adam" ; owes = @{}; owed_by = @{}; balance = 0.0}
@{name = "Bob" ; owes = @{Chuck = 3.0}; owed_by = @{}; balance = -3.0}
@{name = "Chuck" ; owes = @{}; owed_by = @{Bob = 3.0}; balance = 3.0}
)
Expand All @@ -105,7 +105,7 @@ Describe "RestApi test cases" {
$got = $api.Post("/iou", '{"lender": "Bob", "borrower": "Adam", "amount": 3.0}')
$want = @{
users = @(
@{name = "Adam" ; owes = @{Bob = 3.0}; owed_by = @{}; balance = -3.0}
@{name = "Adam" ; owes = @{Bob = 3.0}; owed_by = @{}; balance = -3.0}
@{name = "Bob" ; owes = @{Chuck = 3.0}; owed_by = @{Adam = 3.0}; balance = 0.0}
)
}
Expand All @@ -116,15 +116,15 @@ Describe "RestApi test cases" {
It "iou -> lender owes borrower" {
$data = @{
users = @(
@{name = "Adam" ; owes = @{Bob = 3.0}; owed_by = @{}; balance = -3.0}
@{name = "Adam" ; owes = @{Bob = 3.0}; owed_by = @{}; balance = -3.0}
@{name = "Bob" ; owes = @{}; owed_by = @{Adam = 3.0}; balance = 3.0}
)
}
$api = [RestAPI]::new($data)
$got = $api.Post("/iou", '{"lender": "Adam", "borrower": "Bob", "amount": 2.0}')
$want = @{
users = @(
@{name = "Adam" ; owes = @{Bob = 1.0}; owed_by = @{}; balance = -1.0}
@{name = "Adam" ; owes = @{Bob = 1.0}; owed_by = @{}; balance = -1.0}
@{name = "Bob" ; owes = @{}; owed_by = @{Adam = 1.0}; balance = 1.0}
)
}
Expand All @@ -135,15 +135,15 @@ Describe "RestApi test cases" {
It "iou -> lender owes borrower less than new loan" {
$data = @{
users = @(
@{name = "Adam" ; owes = @{Bob = 3.0}; owed_by = @{}; balance = -3.0}
@{name = "Adam" ; owes = @{Bob = 3.0}; owed_by = @{}; balance = -3.0}
@{name = "Bob" ; owes = @{}; owed_by = @{Adam = 3.0}; balance = 3.0}
)
}
$api = [RestAPI]::new($data)
$got = $api.Post("/iou", '{"lender": "Adam", "borrower": "Bob", "amount": 4.0}')
$want = @{
users = @(
@{name = "Adam" ; owes = @{}; owed_by = @{Bob = 1.0}; balance = 1.0}
@{name = "Adam" ; owes = @{}; owed_by = @{Bob = 1.0}; balance = 1.0}
@{name = "Bob" ; owes = @{Adam = 1.0}; owed_by = @{}; balance = -1.0}
)
}
Expand Down
Loading