You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // DatabaseTest.swift
  3. // GMERemittanceTests
  4. //
  5. // Created by InKwon James Kim on 17/07/2019.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import XCTest
  9. @testable import GME_Remit
  10. class DatabaseTest: XCTestCase {
  11. let testUserJson =
  12. """
  13. {
  14. "Id" : "",
  15. "Extra" : "",
  16. "Extra2" : "",
  17. "Data" : {
  18. "accessCode" : null,
  19. "accessTokenRegTime" : "",
  20. "kyc" : false,
  21. "mobileNumber" : "",
  22. "provinceId" : "",
  23. "availableBalance" : "0",
  24. "country" : "",
  25. "ErrorCode" : "0",
  26. "pennyTestStatus" : "0",
  27. "accessTokenExpTime" : "",
  28. "Extra" : "",
  29. "firstName" : "iosDemo@gmeremit.com",
  30. "Data" : null,
  31. "yearlyLimit" : "30,000",
  32. "dob" : "1988-03-27",
  33. "dpUrl" : null,
  34. "email" : "iosDemo@gmeremit.com",
  35. "sourceId" : "",
  36. "countryCode" : "",
  37. "senderId" : "17",
  38. "active" : true,
  39. "appUpdate" : [
  40. {
  41. "Info" : "This version of the app is out of date and will stop working soon. To keep using GME, please install the latest update.",
  42. "OS" : "IOS",
  43. "Build" : "6",
  44. "Version" : "2.2.2",
  45. "Critical" : "Y"
  46. },
  47. {
  48. "Info" : "This version of the app is out of date and will stop working soon. To keep using GME, please install the latest update.",
  49. "OS" : "ANDROID",
  50. "Build" : "17",
  51. "Version" : "2.3.0",
  52. "Critical" : "Y"
  53. }
  54. ],
  55. "Extra2" : "",
  56. "isReferred" : false,
  57. "rewardPoint" : "0",
  58. "province" : "",
  59. "cmRegistrationId" : "",
  60. "Msg" : "",
  61. "primaryBankName" : "",
  62. "Id" : "",
  63. "verified" : false,
  64. "walletNumber" : "",
  65. "userId" : "iosDemo@gmeremit.com",
  66. "kftcClientId" : null
  67. },
  68. "ErrorCode" : "0",
  69. "Msg" : "success"
  70. }
  71. """
  72. func testSetUser() {
  73. let object = UserContainer(JSONString: testUserJson)
  74. GMEDB
  75. .shared
  76. .setUser(object?.data)
  77. .debugPrintAllElement()
  78. XCTAssert(GMEDB.shared.user.string(.availableBalance) == Optional("0"))
  79. XCTAssert(GMEDB.shared.user.string(.country) == Optional(""))
  80. XCTAssert(GMEDB.shared.user.string(.errorCode) == nil)
  81. XCTAssert(GMEDB.shared.user.string(.pennyTestStatusCode) == Optional("0"))
  82. XCTAssert(GMEDB.shared.user.string(.firstName) == Optional("iosDemo@gmeremit.com"))
  83. XCTAssert(GMEDB.shared.user.string(.data) == nil)
  84. XCTAssert(GMEDB.shared.user.string(.yearlyLimit) == Optional("30,000"))
  85. XCTAssert(GMEDB.shared.user.string(.dateOfBirth) == Optional("1988-03-27"))
  86. XCTAssert(GMEDB.shared.user.string(.senderId) == Optional("17"))
  87. }
  88. func testRemoveAll() {
  89. GMEDB
  90. .shared
  91. .user
  92. .removeAll()
  93. .debugPrintAllElement()
  94. XCTAssert(GMEDB.shared.user.string(.availableBalance) == nil)
  95. XCTAssert(GMEDB.shared.user.string(.country) == nil)
  96. XCTAssert(GMEDB.shared.user.string(.errorCode) == nil)
  97. XCTAssert(GMEDB.shared.user.string(.pennyTestStatusCode) == nil)
  98. XCTAssert(GMEDB.shared.user.string(.firstName) == nil)
  99. XCTAssert(GMEDB.shared.user.string(.data) == nil)
  100. XCTAssert(GMEDB.shared.user.string(.yearlyLimit) == nil)
  101. XCTAssert(GMEDB.shared.user.string(.dateOfBirth) == nil)
  102. XCTAssert(GMEDB.shared.user.string(.senderId) == nil)
  103. }
  104. }