Add tests for remainder of MASError

This commit is contained in:
Ben Chatelain 2018-02-11 16:18:57 -07:00
parent 9347b44547
commit 47dfe5e222

View file

@ -29,7 +29,8 @@ class MASErrorTestCase: XCTestCase {
override func setUp() { override func setUp() {
super.setUp() super.setUp()
nserror = NSError(domain: errorDomain, code: 999) //, userInfo: ["NSLocalizedDescriptionKey": "foo"]) nserror = NSError(domain: errorDomain, code: 999)
localizedDescription = "foo"
} }
override func tearDown() { override func tearDown() {
@ -49,8 +50,52 @@ class MASErrorTestCase: XCTestCase {
} }
func testSignInFailedError() { func testSignInFailedError() {
localizedDescription = "foo"
error = .signInFailed(error: nserror) error = .signInFailed(error: nserror)
XCTAssertEqual("Sign in failed: foo", error.description) XCTAssertEqual(error.description, "Sign in failed: foo")
}
func testAlreadySignedIn() {
error = .alreadySignedIn
XCTAssertEqual(error.description, "Already signed in")
}
func testPurchaseFailed() {
error = .purchaseFailed(error: nil)
XCTAssertEqual(error.description, "Download request failed")
}
func testPurchaseFailedError() {
error = .purchaseFailed(error: nserror)
XCTAssertEqual(error.description, "Download request failed: foo")
}
func testDownloadFailed() {
error = .downloadFailed(error: nil)
XCTAssertEqual(error.description, "Download failed")
}
func testDownloadFailedError() {
error = .downloadFailed(error: nserror)
XCTAssertEqual(error.description, "Download failed: foo")
}
func testNoDownloads() {
error = .noDownloads
XCTAssertEqual(error.description, "No downloads began")
}
func testCancelled() {
error = .cancelled
XCTAssertEqual(error.description, "Download cancelled")
}
func testSearchFailed() {
error = .searchFailed
XCTAssertEqual(error.description, "Search failed")
}
func testNoSearchResultsFound() {
error = .noSearchResultsFound
XCTAssertEqual(error.description, "No results found")
} }
} }