Mercurial > public > simoleon
comparison SimoleonTests/SimoleonTests.swift @ 173:ad8c6567539d
restart project
author | Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com> |
---|---|
date | Tue, 26 Oct 2021 13:09:17 +0200 |
parents | 3913aff613e8 |
children | 5a9430fd6b4d |
comparison
equal
deleted
inserted
replaced
172:9b0486301fbf | 173:ad8c6567539d |
---|---|
1 // | 1 // |
2 // SimoleonTests.swift | 2 // SimoleonTests.swift |
3 // SimoleonTests | 3 // SimoleonTests |
4 // | 4 // |
5 // Created by Dennis Concepción Martín on 27/8/21. | 5 // Created by Dennis Concepción Martín on 26/10/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 | 20 |
21 func testGetAllCurrencies() throws { | 21 func testExample() throws { |
22 // Create test cases | 22 // This is an example of a functional test case. |
23 let testCases = [1: ["USD/GBP", "EUR/AED"], 2: ["USD/GBP", "USD/EUR"]] | 23 // Use XCTAssert and related functions to verify your tests produce the correct results. |
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 } | 24 } |
57 | 25 |
58 func testPerformanceExample() throws { | 26 func testPerformanceExample() throws { |
59 // This is an example of a performance test case. | 27 // This is an example of a performance test case. |
60 measure { | 28 self.measure { |
61 // Put the code you want to measure the time of here. | 29 // Put the code you want to measure the time of here. |
62 } | 30 } |
63 } | 31 } |
64 | 32 |
65 } | 33 } |