comparison SimoleonTests/SimoleonTests.swift @ 171:70f0625bfcf1

Merge pull request #17 from denniscm190/development open source project committer: GitHub <noreply@github.com>
author Dennis C. M. <dennis@denniscm.com>
date Tue, 12 Oct 2021 16:17:35 +0200
parents 3913aff613e8
children ad8c6567539d
comparison
equal deleted inserted replaced
146:f10b0e188905 171:70f0625bfcf1
1 // 1 //
2 // SimoleonTests.swift 2 // SimoleonTests.swift
3 // SimoleonTests 3 // SimoleonTests
4 // 4 //
5 // Created by Dennis Concepción Martín on 08/07/2021. 5 // Created by Dennis Concepción Martín on 27/8/21.
6 // 6 //
7 7
8 import XCTest 8 import XCTest
9 @testable import Simoleon 9 @testable import Simoleon
10 10
15 } 15 }
16 16
17 override func tearDownWithError() throws { 17 override func tearDownWithError() throws {
18 // Put teardown code here. This method is called after the invocation of each test method in the class. 18 // Put teardown code here. This method is called after the invocation of each test method in the class.
19 } 19 }
20
21 func testGetAllCurrencies() throws {
22 // Create test cases
23 let testCases = [1: ["USD/GBP", "EUR/AED"], 2: ["USD/GBP", "USD/EUR"]]
24 let expectedResults = [1: ["USD", "EUR"], 2: ["USD"]]
25
26 // Test
27 let currencySelector = CurrencySelector(currencyConversion: CurrencyConversion())
28 for testCaseNumber in testCases.keys {
29 print("Testing case: \(testCaseNumber)")
30 let mockData = testCases[testCaseNumber]!
31 let allCurrencies = currencySelector.get(currencyType: .all, from: mockData)
32
33 // Assert
34 XCTAssertEqual(allCurrencies, expectedResults[testCaseNumber])
35 }
36 }
37
38 func testGetCompatibleCurrencies() throws {
39 // Create test cases
40 let testCases = [1: ["USD/GBP", "EUR/AED"], 2: ["USD/GBP", "USD/EUR"], 3: ["EUR/AED"]]
41 let expectedResults = [1: ["GBP"], 2: ["GBP", "EUR"], 3: []]
42
43 // Test
44 let currencySelector = CurrencySelector(currencyConversion: CurrencyConversion())
45 for testCaseNumber in testCases.keys {
46 print("Testing case: \(testCaseNumber)")
47 let mockData = testCases[testCaseNumber]!
48 let compatibleCurrencies =
49 currencySelector.get(
50 currencyType: .compatible(with: currencySelector.currencyConversion.baseSymbol), from: mockData
51 )
52
53 // Assert
54 XCTAssertEqual(compatibleCurrencies, expectedResults[testCaseNumber])
55 }
56 }
20 57
21 func testPerformanceExample() throws { 58 func testPerformanceExample() throws {
22 // This is an example of a performance test case. 59 // This is an example of a performance test case.
23 self.measure { 60 measure {
24 // Put the code you want to measure the time of here. 61 // Put the code you want to measure the time of here.
25 } 62 }
26 } 63 }
64
27 } 65 }