view SimoleonTests/SimoleonTests.swift @ 183:d2398f02e1ce

implement unit currency selector
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Mon, 20 Dec 2021 12:28:16 +0100
parents ba3ebe8cefe5
children 2fc95efcb1ee
line wrap: on
line source

//
//  SimoleonTests.swift
//  SimoleonTests
//
//  Created by Dennis Concepción Martín on 8/12/21.
//

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.
    }

    override func tearDownWithError() throws {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
    }
    
    func testGetBaseCurrencies() throws {
        let baseCurrency = SupportedCurrencyResult(code: "EUR", name: "Euro", isCrypto: 0)
        let quoteCurrency = SupportedCurrencyResult(code: "CHF", name: "Swiss Franc", isCrypto: 0)
        let currencyList = CurrencyList(
            baseCurrency: .constant(baseCurrency),
            quoteCurrency: .constant(quoteCurrency),
            selecting: .baseCurrency
        )
        
        let baseCurrencies = currencyList.getCurrencies()
        XCTAssertEqual(baseCurrencies.count, 5, "Base currencies does not match")
    }
    
    func testGetQuoteCurrencies() throws {
        let baseCurrency = SupportedCurrencyResult(code: "EUR", name: "Euro", isCrypto: 0)
        let quoteCurrency = SupportedCurrencyResult(code: "CHF", name: "Swiss Franc", isCrypto: 0)
        let currencyList = CurrencyList(
            baseCurrency: .constant(baseCurrency),
            quoteCurrency: .constant(quoteCurrency),
            selecting: .quoteCurrency
        )
        
        let quoteCurrencies = currencyList.getCurrencies()
        XCTAssertEqual(quoteCurrencies.count, 18, "Quote currencies does not match")
    }

    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.
        }
    }

}