-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d820a4
commit f5479d3
Showing
5 changed files
with
139 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,57 @@ import ObjectMapper | |
class TransactionTest: XCTestCase { | ||
|
||
func testTransactionMapperShouldReturnATransaction() { | ||
let transaction = Mapper<Transaction>().map("{\"id\":\"foobar\",\"type\":\"transfer\",\"message\":\"foobar message\",\"status\":\"pending\",\"RefundedById\":\"foobiz\",\"createdAt\":\"fuz\",\"denomination\":{\"amount\":\"0.1\",\"currency\":\"BTC\",\"pair\":\"BTCBTC\",\"rate\":\"1.00\"},\"origin\":{\"CardId\":\"fizbiz\",\"amount\":\"0.1\",\"base\":\"0.1\",\"commission\":\"0.00\",\"currency\":\"BTC\",\"description\":\"Fuz Buz\",\"fee\":\"0.00\",\"rate\":\"1.00\",\"sources\":[{\"id\":\"fizbuz\",\"amount\":\"2.00\"}],\"type\":\"card\",\"username\":\"fuzbuz\"},\"destination\":{\"CardId\": \"fuzbuz\", \"amount\":\"0.1\",\"base\":\"0.1\",\"commission\":\"0.00\",\"currency\":\"BTC\",\"description\":\"[email protected]\",\"fee\":\"0.00\",\"rate\":\"1.00\",\"type\":\"email\", \"username\": \"fizbiz\"},\"params\":{\"currency\":\"BTC\",\"margin\":\"0.00\",\"pair\":\"BTCBTC\",\"rate\":\"1.00\",\"ttl\":30000,\"type\":\"invite\"}}") | ||
let json: String = "{" + | ||
"\"id\": \"foobar\"," + | ||
"\"type\": \"transfer\"," + | ||
"\"message\": \"foobar message\"," + | ||
"\"status\": \"pending\"," + | ||
"\"RefundedById\": \"foobiz\"," + | ||
"\"createdAt\": \"fuz\"," + | ||
"\"denomination\": {" + | ||
"\"amount\": \"0.1\"," + | ||
"\"currency\": \"BTC\"," + | ||
"\"pair\": \"BTCBTC\"," + | ||
"\"rate\": \"1.00\"" + | ||
"}," + | ||
"\"origin\": {" + | ||
"\"CardId\": \"fizbiz\"," + | ||
"\"amount\": \"0.1\"," + | ||
"\"base\": \"0.1\"," + | ||
"\"commission\": \"0.00\"," + | ||
"\"currency\": \"BTC\"," + | ||
"\"description\": \"Fuz Buz\"," + | ||
"\"fee\": \"0.00\"," + | ||
"\"rate\": \"1.00\"," + | ||
"\"sources\": [{" + | ||
"\"id\": \"fizbuz\"," + | ||
"\"amount\": \"2.00\"" + | ||
"}]," + | ||
"\"type\": \"card\"," + | ||
"\"username\": \"fuzbuz\"" + | ||
"}," + | ||
"\"destination\": {" + | ||
"\"CardId\": \"fuzbuz\"," + | ||
"\"amount\": \"0.1\"," + | ||
"\"base\": \"0.1\"," + | ||
"\"commission\": \"0.00\"," + | ||
"\"currency\": \"BTC\"," + | ||
"\"description\": \"[email protected]\"," + | ||
"\"fee\": \"0.00\"," + | ||
"\"rate\": \"1.00\"," + | ||
"\"type\": \"email\"," + | ||
"\"username\": \"fizbiz\"" + | ||
"}," + | ||
"\"params\": {" + | ||
"\"currency\": \"BTC\"," + | ||
"\"margin\": \"0.00\"," + | ||
"\"pair\": \"BTCBTC\"," + | ||
"\"rate\": \"1.00\"," + | ||
"\"ttl\": 30000," + | ||
"\"type\": \"invite\"" + | ||
"}" + | ||
"}" | ||
let transaction = Mapper<Transaction>().map(json) | ||
|
||
XCTAssertEqual(transaction!.id!, "foobar", "Failed: Transaction id didn't match.") | ||
XCTAssertEqual(transaction!.createdAt!, "fuz", "Failed: Transaction createdAt didn't match.") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,37 @@ import ObjectMapper | |
class UserTest: XCTestCase { | ||
|
||
func testUserMapperShouldReturnAUser() { | ||
let user = Mapper<User>().map("{\"country\":\"US\",\"currencies\":[\"BTC\"],\"email\":\"[email protected]\",\"firstName\":\"Foo\",\"lastName\":\"Bar\",\"name\":\"Foo Bar\",\"settings\":{\"currency\":\"USD\",\"hasOtpEnabled\":true,\"hasNewsSubscription\":true,\"intl\":{\"dateTimeFormat\":{\"locale\":\"foo\"},\"language\":{\"locale\":\"bar\"},\"numberFormat\":{\"locale\":\"biz\"}},\"theme\":\"vintage\"},\"state\":\"WA\",\"status\":\"ok\",\"username\":\"foobar\"}") | ||
let json: String = "{" + | ||
"\"country\": \"US\"," + | ||
"\"currencies\": [" + | ||
"\"BTC\"" + | ||
"]," + | ||
"\"email\": \"[email protected]\"," + | ||
"\"firstName\": \"Foo\"," + | ||
"\"lastName\": \"Bar\"," + | ||
"\"name\": \"Foo Bar\"," + | ||
"\"settings\": {" + | ||
"\"currency\": \"USD\"," + | ||
"\"hasOtpEnabled\": true," + | ||
"\"hasNewsSubscription\": true," + | ||
"\"intl\": {" + | ||
"\"dateTimeFormat\": {" + | ||
"\"locale\": \"foo\"" + | ||
"}," + | ||
"\"language\": {" + | ||
"\"locale\": \"bar\"" + | ||
"}," + | ||
"\"numberFormat\": {" + | ||
"\"locale\": \"biz\"" + | ||
"}" + | ||
"}," + | ||
"\"theme\": \"vintage\"" + | ||
"}," + | ||
"\"state\": \"WA\"," + | ||
"\"status\": \"ok\"," + | ||
"\"username\": \"foobar\"" + | ||
"}" | ||
let user = Mapper<User>().map(json) | ||
|
||
XCTAssertEqual(user!.country!, "US", "Failed: User country didn't match.") | ||
XCTAssertEqual(user!.currencies!.count, 1, "Failed: User currencies didn't match.") | ||
|