Last active
May 8, 2018 19:59
-
-
Save llinardos/374b03559c449171f4cd3d3b7ba7bc52 to your computer and use it in GitHub Desktop.
This file contains 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 ServicesTest: XCTestCase { | |
let service = ProfileService() | |
setup() { | |
// handle authentication if needed | |
// let authService = ... | |
// let authMethod = ... | |
// authService.auth(authMethod) | |
} | |
func create(profile: Profile) -> Result<Profile> { | |
let createResult = service.createProfile(profile) | |
let getResult = service.getProfile() | |
return getResult | |
} | |
func assertEqualProfiles(_ expected: Profile, _ getResult: Result<Profile>) { | |
do { | |
let updatedProfile = try getResult.get() | |
XCTAssertEquals(expected.name, updatedProfile.name) | |
XCTAssertEquals(expected.thing, updatedProfile.thing) | |
} catch { | |
XCTFails() | |
} | |
} | |
func testCreateProfileWithThing() { | |
let profile = Profile(name: "Name", thing: Thing()) | |
let result = create(profile: profile) | |
assertEqualProfiles(profile, result.get()) | |
} | |
func testCreateProfileWithoutThing() { | |
let profile = Profile(name: "Name", thing: nil) | |
let result = create(profile: profile) | |
assertEqualProfiles(profile, result.get()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment