comparison SimoleonTests/SimoleonTests.swift @ 154:8afba86ab8dd

Refactor code
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Wed, 25 Aug 2021 10:43:12 +0100
parents 2590ee472aa9
children 8c3bbd640103
comparison
equal deleted inserted replaced
153:2590ee472aa9 154:8afba86ab8dd
7 7
8 import XCTest 8 import XCTest
9 @testable import Simoleon 9 @testable import Simoleon
10 10
11 class SimoleonTests: XCTestCase { 11 class SimoleonTests: XCTestCase {
12 let fileController = FileController()
12 13
13 override func setUpWithError() throws { 14 override func setUpWithError() throws {
14 // Put setup code here. This method is called before the invocation of each test method in the class. 15 // Put setup code here. This method is called before the invocation of each test method in the class.
15 continueAfterFailure = false 16 continueAfterFailure = false
16 } 17 }
18 override func tearDownWithError() throws { 19 override func tearDownWithError() throws {
19 // Put teardown code here. This method is called after the invocation of each test method in the class. 20 // Put teardown code here. This method is called after the invocation of each test method in the class.
20 } 21 }
21 22
22 func testReadJson() throws { 23 func testReadJson() throws {
23 let currencyPairsSupported: [String]? = try? read(json: "CurrencyPairsSupported.json") 24 let currencyPairsSupported: [String]? = try? fileController.read(json: "CurrencyPairsSupported.json")
24 XCTAssertNotNil(currencyPairsSupported, "An error occurred while reading CurrencyPairsSupported.json") 25 XCTAssertNotNil(currencyPairsSupported, "An error occurred while reading CurrencyPairsSupported.json")
25 26
26 let currencyDetails: [String: CurrencyDetailsModel]? = try? read(json: "CurrencyDetails.json") 27 let currencyDetails: [String: CurrencyDetailsModel]? = try? fileController.read(json: "CurrencyDetails.json")
27 XCTAssertNotNil(currencyDetails, "An error occurred while reading CurrencyDetails.json") 28 XCTAssertNotNil(currencyDetails, "An error occurred while reading CurrencyDetails.json")
28 } 29 }
29 30
30 func testCurrencyExistence() throws { 31 func testCurrencyExistence() throws {
31 let currencyDetails: [String: CurrencyDetailsModel] = try! read(json: "CurrencyDetails.json") 32 let currencyDetails: [String: CurrencyDetailsModel] = try! fileController.read(json: "CurrencyDetails.json")
32 33
33 // Remove duplicates from currency pairs supported 34 // Remove duplicates from currency pairs supported
34 let currencyPairsSupported: [String] = try! read(json: "CurrencyPairsSupported.json") 35 let currencyPairsSupported: [String] = try! fileController.read(json: "CurrencyPairsSupported.json")
35 var currenciesSupported = Set<String>() 36 var currenciesSupported = Set<String>()
36 37
37 for currencyPairSupported in currencyPairsSupported { 38 for currencyPairSupported in currencyPairsSupported {
38 let symbols = currencyPairSupported.components(separatedBy: "/") 39 let symbols = currencyPairSupported.components(separatedBy: "/")
39 for symbol in symbols { 40 for symbol in symbols {