Mercurial > public > simoleon
view SimoleonTests/SimoleonTests.swift @ 153:2590ee472aa9
Add test to check currency existence
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Mon, 23 Aug 2021 17:14:47 +0100 |
parents | bdedd0cc6cd1 |
children | 8afba86ab8dd |
line wrap: on
line source
// // SimoleonTests.swift // SimoleonTests // // Created by Dennis Concepción Martín on 08/07/2021. // import XCTest @testable import Simoleon class SimoleonTests: XCTestCase { override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. continueAfterFailure = false } override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. } func testReadJson() throws { let currencyPairsSupported: [String]? = try? read(json: "CurrencyPairsSupported.json") XCTAssertNotNil(currencyPairsSupported, "An error occurred while reading CurrencyPairsSupported.json") let currencyDetails: [String: CurrencyDetailsModel]? = try? read(json: "CurrencyDetails.json") XCTAssertNotNil(currencyDetails, "An error occurred while reading CurrencyDetails.json") } func testCurrencyExistence() throws { let currencyDetails: [String: CurrencyDetailsModel] = try! read(json: "CurrencyDetails.json") // Remove duplicates from currency pairs supported let currencyPairsSupported: [String] = try! read(json: "CurrencyPairsSupported.json") var currenciesSupported = Set<String>() for currencyPairSupported in currencyPairsSupported { let symbols = currencyPairSupported.components(separatedBy: "/") for symbol in symbols { currenciesSupported.insert(symbol) XCTAssertNotNil(currencyDetails[symbol], "Currency details of symbol: \(symbol) can't be found") XCTAssertTrue((UIImage(named: currencyDetails[symbol]!.flag) != nil), "Flag of symbol: \(symbol) can't be found") } } // Check if there are same number of currencies XCTAssertEqual(currencyDetails.keys.count, currenciesSupported.count) } func testPerformanceExample() throws { // This is an example of a performance test case. self.measure { // Put the code you want to measure the time of here. } } }