Last active
April 18, 2020 19:31
-
-
Save cipolleschi/98ce370b355a80dad18b6dcacdae6fa0 to your computer and use it in GitHub Desktop.
Test by using protocols
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
| import XCTest | |
| import Foundation | |
| /// File manager stub to override the methods we need | |
| class FileManagerStub: AppFileManager { | |
| func getContent(atPath: Stirng) -> Data? { | |
| return Data() | |
| } | |
| } | |
| /// Class under test | |
| class MyViewControllerTest: XCTestCase { | |
| func testLoadContent_withEmptyFile() { | |
| let vc = MyViewController() | |
| let fileManagerStub = FileManagerStub() | |
| let decoder: JSONDecoder = JSONDecoder() | |
| vc.loadContent(fileManager: fileManagerStub, path: "emptyFile", jsonDecoder: decoder) | |
| XCTAssertTrue(vc.content.isEmpty) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment