-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPillTestFixtures.swift
62 lines (55 loc) · 1.99 KB
/
PillTestFixtures.swift
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
//
// TestPillAttributesFactory.swift
// PDTest
//
// Created by Juliya Smith on 8/4/21.
// Copyright © 2021 Juliya Smith. All rights reserved.
//
import Foundation
import PDKit
import XCTest
public class PillTestFixtures {
public static func createAttributesForXDaysOnXDaysOff(
daysOne: Int?=nil, daysTwo: Int?=nil, isOn: Bool?=nil, daysPosition: Int?=nil
) -> PillAttributes {
let attributes = PillAttributes()
attributes.expirationInterval.value = .XDaysOnXDaysOff
attributes.expirationInterval.daysOne = daysOne
attributes.expirationInterval.daysTwo = daysTwo
attributes.expirationInterval.xDaysIsOn = isOn
attributes.expirationInterval.xDaysPosition = daysPosition
return attributes
}
public static func assertPosition(
_ expectedPosition: Int,
_ expectedBool: Bool,
_ interval: PillExpirationInterval,
file: StaticString = #filePath,
line: UInt = #line
) {
guard let isOn = interval.xDaysIsOn else {
XCTFail("XDays position is not turned on.", file: file, line: line)
return
}
guard let position = interval.xDaysPosition else {
XCTFail("XDays position is not initialized.", file: file, line: line)
return
}
let failIsOnMessage = expectedBool ? "XDays is NOT on" : "XDays is on"
let failPositionMessage = "Expected position \(expectedPosition); actually at \(position)."
if expectedBool != isOn {
XCTFail(failIsOnMessage, file: file, line: line)
}
if expectedPosition != position {
XCTFail(failPositionMessage, file: file, line: line)
}
}
public static func assertNilPosition(
_ interval: PillExpirationInterval,
file: StaticString = #filePath,
line: UInt = #line
) {
XCTAssertNil(interval.xDaysIsOn, file: file, line: line)
XCTAssertNil(interval.xDaysPosition, file: file, line: line)
}
}