Skip to content

Commit

Permalink
Merge pull request #7 from crelies/dev
Browse files Browse the repository at this point in the history
more unit tests, fixed xc test manifests
  • Loading branch information
Chris authored Feb 23, 2020
2 parents 6fa244d + f0f6c4a commit 51ed9bf
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ final class URLSession_RemoteImageURLDataPublisherTests: XCTestCase {
let dataPublisher = urlSession.dataPublisher(for: urlRequest)
XCTAssertEqual(dataPublisher.description, dataTaskPublisher.description)
}

static var allTests = [
("testDataPublisher", testDataPublisher)
]
}
12 changes: 12 additions & 0 deletions Tests/RemoteImageTests/Models/PhotoKitServiceErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,16 @@ final class PhotoKitServiceErrorTests: XCTestCase {
func testErrorDomain() {
XCTAssertEqual(PhotoKitServiceError.errorDomain, String(describing: PhotoKitService.self))
}

static var allTests = [
("testMissingDataErrorDescription", testMissingDataErrorDescription),
("testMissingDataFailureReason", testMissingDataFailureReason),
("testMissingDataRecoverySuggestion", testMissingDataRecoverySuggestion),
("testMissingDataErrorCode", testMissingDataErrorCode),
("testPhAssetNotFoundErrorDescription", testPhAssetNotFoundErrorDescription),
("testPhAssetNotFoundFailureReason", testPhAssetNotFoundFailureReason),
("testPhAssetNotFoundRecoverySuggestion", testPhAssetNotFoundRecoverySuggestion),
("testPhAssetNotFoundErrorCode", testPhAssetNotFoundErrorCode),
("testErrorDomain", testErrorDomain)
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ final class RemoteImageServiceErrorTests: XCTestCase {
let expectedDescription = "Could not create image from received data"
XCTAssertEqual(description, expectedDescription)
}

static var allTests = [
("testCouldNotCreateImageDescription", testCouldNotCreateImageDescription)
]
}
43 changes: 43 additions & 0 deletions Tests/RemoteImageTests/Models/RemoteImageStateTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// RemoteImageStateTests.swift
// RemoteImageTests
//
// Created by Christian Elies on 23.02.20.
//

#if canImport(UIKit)
@testable import RemoteImage
import UIKit
import XCTest

final class RemoteImageStateTests: XCTestCase {
func testErrorValue() {
let error = NSError(domain: "MockDomain", code: 1, userInfo: nil)
let state: RemoteImageState = .error(error)
XCTAssertEqual(state.error, error)
}

func testNoErrorValue() {
let state: RemoteImageState = .loading
XCTAssertNil(state.error)
}

func testImageValue() {
let image = UIImage()
let state: RemoteImageState = .image(image)
XCTAssertEqual(state.image, image)
}

func testNoImageValue() {
let state: RemoteImageState = .loading
XCTAssertNil(state.image)
}

static var allTests = [
("testErrorValue", testErrorValue),
("testNoErrorValue", testNoErrorValue),
("testImageValue", testImageValue),
("testNoImageValue", testNoImageValue)
]
}
#endif
6 changes: 6 additions & 0 deletions Tests/RemoteImageTests/Services/PhotoKitServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,10 @@ final class PhotoKitServiceTests: XCTestCase {
XCTFail("Invalid photo data result")
}
}

static var allTests = [
("testPhotoDataNotFound", testPhotoDataNotFound),
("testPhotoDataFailure", testPhotoDataFailure),
("testPhotoDataSuccess", testPhotoDataSuccess)
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ final class RemoteImageServiceDependenciesTests: XCTestCase {
XCTAssertTrue(dependencies.photoKitService is PhotoKitService)
XCTAssertTrue(dependencies.remoteImageURLDataPublisher is URLSession)
}

static var allTests = [
("testInitialization", testInitialization)
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ final class RemoteImageServiceFactoryTests: XCTestCase {
let service = RemoteImageServiceFactory.makeRemoteImageService()
XCTAssertEqual(service.state, .loading)
}

static var allTests = [
("testMakeRemoteImageService", testMakeRemoteImageService)
]
}
#endif
11 changes: 11 additions & 0 deletions Tests/RemoteImageTests/Services/RemoteImageServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,16 @@ final class RemoteImageServiceTests: XCTestCase {
XCTFail("Invalid fetch ph asset cached result")
}
}

static var allTests = [
("testFetchImageURLSuccess", testFetchImageURLSuccess),
("testFetchImageURLFailure", testFetchImageURLFailure),
("testFetchImageURLFailureCompletion", testFetchImageURLFailureCompletion),
("testFetchImageURLCached", testFetchImageURLCached),
("testFetchPHAssetSuccess", testFetchPHAssetSuccess),
("testFetchPHAccessInvalidData", testFetchPHAccessInvalidData),
("testFetchPHAccessFailure", testFetchPHAccessFailure),
("testFetchPHAssetCached", testFetchPHAssetCached)
]
}
#endif
4 changes: 4 additions & 0 deletions Tests/RemoteImageTests/Views/RemoteImageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ final class RemoteImageTests: XCTestCase {
XCTFail("\(error)")
}
}

static var allTests = [
("testLoadingState", testLoadingState)
]
}
#endif
11 changes: 10 additions & 1 deletion Tests/RemoteImageTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ import XCTest
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(DefaultRemoteImageCacheTests.allTests)
testCase(DefaultRemoteImageCacheTests.allTests),
testCase(PhotoKitServiceErrorTests.allTests),
testCase(PhotoKitServiceTests.allTests),
testCase(RemoteImageTests.allTests),
testCase(RemoteImageServiceDependenciesTests.allTests),
testCase(RemoteImageServiceErrorTests.allTests),
testCase(RemoteImageServiceFactoryTests.allTests),
testCase(RemoteImageServiceTests.allTests),
testCase(RemoteImageStateTests.allTests),
testCase(URLSession_RemoteImageURLDataPublisherTests.allTests)
]
}
#endif

0 comments on commit 51ed9bf

Please sign in to comment.