Last active
July 5, 2020 19:04
-
-
Save Kdan/3408e367de23f6b016040549b338d465 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ATests: XCTestCase { | |
| /// The testable `A` class. | |
| private var a: A! | |
| /// The mocked `B` class injected to `a`. | |
| private var b: BMock! | |
| override func setUp() { | |
| super.setUp() | |
| b = BMock() | |
| a = A(b: b) | |
| } | |
| // MARK: - Initialiser | |
| func testInitialiser() { | |
| XCTAssertFalse(a.hasAnswer) | |
| } | |
| // MARK: - checkAnswer() | |
| // When `b` returns true, `hasAnswer` should be true. | |
| func testCheckAnswerTrue() { | |
| b.validateAnswerResponse = true | |
| a.checkAnswer() | |
| XCTAssertTrue(a.hasAnswer) | |
| } | |
| // When `b` returns false, `hasAnswer` should be false. | |
| func testCheckAnswerFalse() { | |
| b.validateAnswerResponse = false | |
| a.checkAnswer() | |
| XCTAssertFalse(a.hasAnswer) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment