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.

297 lines
6.8 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
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
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // APITest.swift
  3. // GMERemittanceTests
  4. //
  5. // Created by InKwon Devik Kim on 03/05/2019.
  6. // Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import XCTest
  9. @testable import GME_Remit
  10. class APITest: XCTestCase {
  11. func testProductList() {
  12. let service = RewardService()
  13. let expt = expectation(description: "ProductList")
  14. service.fetchProductList(success: {
  15. print("success: \($0?.count ?? 0)")
  16. expt.fulfill()
  17. }, failure: {
  18. print("Error: \($0.localizedDescription)")
  19. expt.fulfill()
  20. })
  21. wait(for: [expt], timeout: 5.0)
  22. }
  23. func testFetchBankList() {
  24. let service = AddAccountService()
  25. let expt = expectation(description: "testFetchBankList")
  26. service.fetchBankList(
  27. success: {
  28. print("banks: \($0?.count ?? 0)")
  29. expt.fulfill()
  30. },
  31. failure: {
  32. print("error: \($0.localizedDescription)")
  33. expt.fulfill()
  34. }
  35. )
  36. wait(for: [expt], timeout: 5.0)
  37. }
  38. func testRealName() {
  39. // let service = AddAccountService()
  40. // let expt = expectation(description: "testRealName")
  41. //
  42. // var params = ["CustomerId": "85074"]
  43. // params["BankCode"] = "034"
  44. // params["AccountNumber"] = "1234512345"
  45. //
  46. // service.verifyAccountService(
  47. // using: params,
  48. // success: {
  49. // expt.fulfill()
  50. // },
  51. // failure: {
  52. // print("error: \($0)")
  53. // expt.fulfill()
  54. // }
  55. // )
  56. // wait(for: [expt], timeout: 5.0)
  57. }
  58. func testFetchOrderHistory() {
  59. let service = OrderHistoryService()
  60. let expt = expectation(description: "testFetchOrderHistory")
  61. service.fetchOrderHistory(
  62. from: "2019-05-01",
  63. to: "2019-05-11",
  64. success: { _ in
  65. expt.fulfill()
  66. },
  67. failure: { _ in
  68. expt.fulfill()
  69. }
  70. )
  71. wait(for: [expt], timeout: 5.0)
  72. }
  73. func testFetchHotLines() {
  74. // let service = HomeService()
  75. // service.fetchHotLines()
  76. }
  77. func testKFTCRefrsh() {
  78. let service = AutoDebitService()
  79. let service2 = AddAccountService()
  80. let expt = expectation(description: "Test KFTC Refresh")
  81. service.refreshTokenStep1(
  82. username: "maxkim@gmeremit.com",
  83. success: {
  84. let url = "\($0?.url?.replacingOccurrences(of: "&lang=", with: "&lang=kor") ?? "")"
  85. var header = [String: String]()
  86. $0?.header?.forEach({
  87. header[$0.key ?? ""] = $0.value ?? ""
  88. })
  89. service2.fetchKftcUrlService(
  90. url: url,
  91. header: header,
  92. success: {
  93. print("Fetched URL: \($0 ?? "URL IS NULL")")
  94. expt.fulfill()
  95. },
  96. failure: {
  97. print("Fetch URL Error: \($0)")
  98. expt.fulfill()
  99. }
  100. )
  101. },
  102. failure: {
  103. print("Error: \($0)")
  104. expt.fulfill()
  105. }
  106. )
  107. wait(for: [expt], timeout: 60)
  108. }
  109. func testFetchCountryService() {
  110. // let expt = expectation(description: "testDynamicReceiver")
  111. // let service = SetupRecipientService()
  112. }
  113. func testDynamicReceiver() {
  114. let expt = expectation(description: "testDynamicReceiver")
  115. let service = SetupRecipientService()
  116. service.fetchDynamicReceiverFields(
  117. of: "104",
  118. paymentModeID: "2",
  119. success: {
  120. print($0.dynamicField)
  121. expt.fulfill()
  122. },
  123. failure: {
  124. XCTAssert(false, $0.localizedDescription)
  125. expt.fulfill()
  126. }
  127. )
  128. wait(for: [expt], timeout: 5.0)
  129. }
  130. func testFecthRecipients() {
  131. let expt = expectation(description: "testFecthRecipients")
  132. let service = RecipientsService()
  133. service.fetchRecipients(
  134. success: {
  135. print($0.accounts?.count ?? 0)
  136. print($0.recipients?.count ?? 0)
  137. XCTAssert(true)
  138. expt.fulfill()
  139. },
  140. failure: {
  141. XCTAssert(false, $0.localizedDescription)
  142. expt.fulfill()
  143. }
  144. )
  145. wait(for: [expt], timeout: 1000.0)
  146. }
  147. func testFetchBranch() {
  148. let expt = expectation(description: "textFetchBranch")
  149. let service = TablePresenterService()
  150. service.fetchBranches(
  151. countryCode: "",
  152. bankID: "",
  153. branchName: "",
  154. success: {
  155. print($0.count)
  156. expt.fulfill()
  157. XCTAssert(true)
  158. },
  159. failure: {
  160. expt.fulfill()
  161. XCTAssert(false, $0.localizedDescription)
  162. })
  163. wait(for: [expt], timeout: 5.0)
  164. }
  165. func testDomeRemitStart() {
  166. let expt = expectation(description: "testDomeRemitStart")
  167. let service = DomesticRemitService()
  168. service.fetchInformation(
  169. success: {
  170. print($0)
  171. expt.fulfill()
  172. },
  173. failure: {
  174. expt.fulfill()
  175. XCTAssert(false, $0.localizedDescription)
  176. })
  177. wait(for: [expt], timeout: 5.0)
  178. }
  179. func testRecentHistories() {
  180. let expt = expectation(description: "testRecentHistories")
  181. let service = RecentHistoriesService()
  182. service.fetchHistories(
  183. success: {
  184. print($0)
  185. expt.fulfill()
  186. },
  187. failure: {
  188. expt.fulfill()
  189. XCTAssert(false, $0.localizedDescription)
  190. })
  191. wait(for: [expt], timeout: 5.0)
  192. }
  193. func testGetName() {
  194. let expt = expectation(description: "testGetName")
  195. let service = DomesticRemitService()
  196. service.getRecipientName(
  197. account: "",
  198. bankCode: "",
  199. success: {
  200. print($0)
  201. expt.fulfill()
  202. },
  203. failure: {
  204. expt.fulfill()
  205. XCTAssert(false, $0.localizedDescription)
  206. }
  207. )
  208. wait(for: [expt], timeout: 5.0)
  209. }
  210. func testFetchBalance() {
  211. let expt = expectation(description: "testFetchBalance")
  212. let service = DomesticRemitService()
  213. service.fetchBalance(
  214. fintechUseNumber: "",
  215. success: {
  216. print($0)
  217. expt.fulfill()
  218. },
  219. failure: {
  220. expt.fulfill()
  221. XCTAssert(false, $0.localizedDescription)
  222. }
  223. )
  224. wait(for: [expt], timeout: 5.0)
  225. }
  226. func testDomesticTransactionHistories() {
  227. let expt = expectation(description: "testDomesticTransactionHistories")
  228. let service = TransactionHistoryService()
  229. service.fetchDomesticTransactionHistory(
  230. from: "",
  231. to: "",
  232. success: {
  233. print($0)
  234. expt.fulfill()
  235. },
  236. failure: {
  237. expt.fulfill()
  238. XCTAssert(false, $0.localizedDescription)
  239. }
  240. )
  241. wait(for: [expt], timeout: 5.0)
  242. }
  243. func testDomesticReceipt() {
  244. let expt = expectation(description: "testDomesticReceipt")
  245. let service = SendMoneyReceiptService()
  246. service.fetch(
  247. type: .domestic,
  248. transactionId: "",
  249. success: {
  250. print($0)
  251. expt.fulfill()
  252. },
  253. failure: {
  254. expt.fulfill()
  255. XCTAssert(false, $0.localizedDescription)
  256. }
  257. )
  258. wait(for: [expt], timeout: 5.0)
  259. }
  260. }