-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleExpectedValuesTests.swift
More file actions
84 lines (71 loc) · 2.59 KB
/
ExampleExpectedValuesTests.swift
File metadata and controls
84 lines (71 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// ExampleExpectedValuesTests.swift
// Copyright © 2022 Cameron Cooke. All rights reserved.
//
import XCTest
@testable import ParameterizedTesting
final class ExampleExpectedValuesTests: ParameterizedTestCase2<WeatherData.Weather, Int, String> {
// MARK: - Internal -
override class func values() -> ([WeatherData.Weather], [Int]) {
(
[.raining, .sunny, .cloudy, .snowing],
[12, 34, 3, 22, 0]
)
}
override class func expectedValues() -> [String] {
[
"It's raining and a mild 12 degrees celsius",
"It's raining and a hot 34 degrees celsius",
"It's raining and a cold 3 degrees celsius",
"It's raining and a comfortable 22 degrees celsius",
"It's raining and a freezing 0 degrees celsius",
"It's sunny and a mild 12 degrees celsius",
"It's sunny and a hot 34 degrees celsius",
"It's sunny and a cold 3 degrees celsius",
"It's sunny and a comfortable 22 degrees celsius",
"It's sunny and a freezing 0 degrees celsius",
"It's cloudy and a mild 12 degrees celsius",
"It's cloudy and a hot 34 degrees celsius",
"It's cloudy and a cold 3 degrees celsius",
"It's cloudy and a comfortable 22 degrees celsius",
"It's cloudy and a freezing 0 degrees celsius",
"It's snowing and a mild 12 degrees celsius",
"It's snowing and a hot 34 degrees celsius",
"It's snowing and a cold 3 degrees celsius",
"It's snowing and a comfortable 22 degrees celsius",
"It's snowing and a freezing 0 degrees celsius",
]
}
override func testAllCombinations(
_ weather: WeatherData.Weather,
_ temperature: Int,
_ expectedResult: String? = nil
) {
let sut = WeatherData(weather: weather, temperature: temperature)
XCTAssertEqual(sut.summary, expectedResult)
}
}
// MARK: Fakes
struct WeatherData {
enum Weather: String, Hashable, CaseIterable {
case raining
case sunny
case cloudy
case snowing
}
let weather: Weather
let temperature: Int
var summary: String {
"It's \(weather.rawValue) and a \(adjective) \(temperature) degrees celsius"
}
private var adjective: String {
switch temperature {
case ...2: return "freezing"
case 3 ... 10: return "cold"
case 11 ... 19: return "mild"
case 20 ... 25: return "comfortable"
case 25...: return "hot"
default: return ""
}
}
}