Mercurial > public > geoquiz
comparison GeoQuizTests/GeoQuizTests.swift @ 34:6ec51a4ca897
fix crash when asking new questions
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Sat, 12 Nov 2022 14:23:05 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
33:6d574bd1644f | 34:6ec51a4ca897 |
---|---|
1 // | |
2 // GeoQuizTests.swift | |
3 // GeoQuizTests | |
4 // | |
5 // Created by Dennis Concepción Martín on 12/11/22. | |
6 // | |
7 | |
8 import XCTest | |
9 @testable import GeoQuiz | |
10 | |
11 final class GeoQuizTests: XCTestCase { | |
12 | |
13 override func setUpWithError() throws { | |
14 // Put setup code here. This method is called before the invocation of each test method in the class. | |
15 } | |
16 | |
17 override func tearDownWithError() throws { | |
18 // Put teardown code here. This method is called after the invocation of each test method in the class. | |
19 } | |
20 | |
21 func testExample() throws { | |
22 // This is an example of a functional test case. | |
23 // Use XCTAssert and related functions to verify your tests produce the correct results. | |
24 // Any test you write for XCTest can be annotated as throws and async. | |
25 // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. | |
26 // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. | |
27 } | |
28 | |
29 func testPerformanceExample() throws { | |
30 // This is an example of a performance test case. | |
31 measure { | |
32 // Put the code you want to measure the time of here. | |
33 } | |
34 } | |
35 } | |
36 | |
37 final class CountryGameControllerTests: XCTestCase { | |
38 var game: CountryGameController! | |
39 | |
40 @MainActor override func setUpWithError() throws { | |
41 game = CountryGameController() | |
42 } | |
43 | |
44 @MainActor func testAsk() throws { | |
45 for _ in game.data { | |
46 game.ask() | |
47 XCTAssertEqual(game.userChoices.count, 3) | |
48 XCTAssertEqual(Set(game.userChoices.keys).count, 3) | |
49 } | |
50 | |
51 XCTAssertEqual(game.dataAsked.count, game.data.count) | |
52 } | |
53 } | |
54 | |
55 final class CityGameControllerTests: XCTestCase { | |
56 var game: CityGameController! | |
57 | |
58 @MainActor override func setUpWithError() throws { | |
59 game = CityGameController() | |
60 } | |
61 | |
62 @MainActor func testAsk() throws { | |
63 for _ in game.data { | |
64 game.ask() | |
65 XCTAssertEqual(game.userChoices.count, 3) | |
66 XCTAssertEqual(Set(game.userChoices.keys).count, 3) | |
67 } | |
68 | |
69 XCTAssertEqual(game.dataAsked.count, game.data.count) | |
70 } | |
71 } |