Skip to content

Instantly share code, notes, and snippets.

@Juanpe
Last active December 7, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Juanpe/717feef9ca2bf5dbdd8db62ca9c32e71 to your computer and use it in GitHub Desktop.
Save Juanpe/717feef9ca2bf5dbdd8db62ca9c32e71 to your computer and use it in GitHub Desktop.
class ViewControllerWithoutCLTests: XCTestCase {
var sut: ViewControllerWithoutCL!
var locationProvider: UserLocationProviderMock!
override func setUp() {
super.setUp()
locationProvider = UserLocationProviderMock()
sut = ViewControllerWithoutCL(locationProvider: locationProvider)
}
override func tearDown() {
sut = nil
locationProvider = nil
super.tearDown()
}
func testRequestUserLocation_NotAuthorized_ShouldFail() {
// Given
locationProvider.locationBlockLocationValue = UserLocationMock()
locationProvider.locationBlockErrorValue = UserLocationError.canNotBeLocated
// When
sut.requestUserLocation()
// Then
XCTAssertNil(sut.userLocation)
}
func testRequestUserLocation_Authorized_ShouldReturnUserLocation() {
// Given
locationProvider.locationBlockLocationValue = UserLocationMock()
// When
sut.requestUserLocation()
// Then
XCTAssertNotNil(sut.userLocation)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment