Created
November 26, 2018 16:12
-
-
Save fernandodelrio/22d7bf34053b3db40b8cd43ed4a934a7 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
| import XCTest | |
| import Swinject | |
| @testable import ContactApp | |
| class ContactNetworkUnitTests: XCTestCase { | |
| var provider: Providable? | |
| override func setUp() { | |
| super.setUp() | |
| provider = networkContainer.resolve(Providable.self) | |
| } | |
| func testNetworkGetContact() { | |
| let expectation = XCTestExpectation(description: "Request a contact over network") | |
| provider?.get(Contact.self) { [weak self] contact in | |
| guard let contact = contact else { | |
| XCTFail("Contact is nil") | |
| return | |
| } | |
| XCTAssert(contact.name == "Fernando") | |
| XCTAssert(contact.description == "Really cool guy. Lorem ipsum dolor sit amet, consectetur adipiscing elit") | |
| XCTAssert(contact.photoUrl == "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5vpRDuDJqlCCrIUqbLTU65_V44yk1XZjwcOK1H3zkvd-F_b8m") | |
| self?.provider?.getImage(contact.photoUrl) { image in | |
| XCTAssert(image != nil) | |
| expectation.fulfill() | |
| } | |
| } | |
| wait(for: [expectation], timeout: 30.0) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment