diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/PopularTVSeriesRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/PopularTVSeriesRequestTests.swift index 3beb38a1..137e49cd 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/PopularTVSeriesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/PopularTVSeriesRequestTests.swift @@ -17,57 +17,67 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class PopularTVSeriesRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct PopularTVSeriesRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = PopularTVSeriesRequest() - XCTAssertEqual(request.path, "/tv/popular") + #expect(request.path == "/tv/popular") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = PopularTVSeriesRequest() - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithPage() { + @Test("queryItems with page") + func queryItemsWithPage() { let request = PopularTVSeriesRequest(page: 3) - XCTAssertEqual(request.queryItems, ["page": "3"]) + #expect(request.queryItems == ["page": "3"]) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = PopularTVSeriesRequest(language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testQueryItemsWithPageAndLanguage() { + @Test("queryItems with page and language") + func queryItemsWithPageAndLanguage() { let request = PopularTVSeriesRequest(page: 3, language: "en") - XCTAssertEqual(request.queryItems, ["page": "3", "language": "en"]) + #expect(request.queryItems == ["page": "3", "language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = PopularTVSeriesRequest() - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = PopularTVSeriesRequest() - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = PopularTVSeriesRequest() - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/SimilarTVSeriesRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/SimilarTVSeriesRequestTests.swift index e1d905b5..d36e7036 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/SimilarTVSeriesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/SimilarTVSeriesRequestTests.swift @@ -17,57 +17,67 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class SimilarTVSeriesRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct SimilarTVSeriesRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = SimilarTVSeriesRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/similar") + #expect(request.path == "/tv/1/similar") } - func testQueryItemsIsEmpty() { + @Test("queryItem is empty") + func queryItemsIsEmpty() { let request = SimilarTVSeriesRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithPage() { + @Test("queryItems with page") + func queryItemsWithPage() { let request = SimilarTVSeriesRequest(id: 1, page: 3) - XCTAssertEqual(request.queryItems, ["page": "3"]) + #expect(request.queryItems == ["page": "3"]) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = SimilarTVSeriesRequest(id: 1, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testQueryItemsWithPageAndLanguage() { + @Test("queryItems with page and language") + func queryItemsWithPageAndLanguage() { let request = SimilarTVSeriesRequest(id: 1, page: 3, language: "en") - XCTAssertEqual(request.queryItems, ["page": "3", "language": "en"]) + #expect(request.queryItems == ["page": "3", "language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = SimilarTVSeriesRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = SimilarTVSeriesRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = SimilarTVSeriesRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesAggregateCreditsRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesAggregateCreditsRequestTests.swift index 3a1b2b2d..55c7ceef 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesAggregateCreditsRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesAggregateCreditsRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesAggregateCreditsRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesAggregateCreditsRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeriesAggregateCreditsRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/aggregate_credits") + #expect(request.path == "/tv/1/aggregate_credits") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeriesAggregateCreditsRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = TVSeriesAggregateCreditsRequest(id: 1, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeriesAggregateCreditsRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeriesAggregateCreditsRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeriesAggregateCreditsRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesContentRatingsRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesContentRatingsRequestTests.swift index ffd465c2..16ea3b82 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesContentRatingsRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesContentRatingsRequestTests.swift @@ -17,39 +17,46 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesContentRatingsRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesContentRatingsRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = ContentRatingRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/content_ratings") + #expect(request.path == "/tv/1/content_ratings") } - func testQueryItemsIsEmpty() { + @Test("queryItem is empty") + func queryItemsIsEmpty() { let request = ContentRatingRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = ContentRatingRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = ContentRatingRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = ContentRatingRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesCreditsRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesCreditsRequestTests.swift index abebcc18..a15846f7 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesCreditsRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesCreditsRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesCreditsRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesCreditsRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeriesCreditsRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/credits") + #expect(request.path == "/tv/1/credits") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeriesCreditsRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = TVSeriesCreditsRequest(id: 1, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeriesCreditsRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeriesCreditsRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeriesCreditsRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesExternalLinksRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesExternalLinksRequestTests.swift index fa3d3cda..5b0bc350 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesExternalLinksRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesExternalLinksRequestTests.swift @@ -17,41 +17,42 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesExternalLinksRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesExternalLinksRequestTests { var request: TVSeriesExternalLinksRequest! - override func setUp() { - super.setUp() - request = TVSeriesExternalLinksRequest(id: 1) + init() { + self.request = TVSeriesExternalLinksRequest(id: 1) } - override func tearDown() { - request = nil - super.tearDown() + @Test("path is correct") + func path() { + #expect(request.path == "/tv/1/external_ids") } - func testPath() { - XCTAssertEqual(request.path, "/tv/1/external_ids") + @Test("queryItems is empty") + func queryItemsIsEmpty() { + #expect(request.queryItems.isEmpty) } - func testQueryItemsIsEmpty() { - XCTAssertTrue(request.queryItems.isEmpty) + @Test("method is GET") + func methodIsGet() { + #expect(request.method == .get) } - func testMethodIsGet() { - XCTAssertEqual(request.method, .get) + @Test("headers is empty") + func headersIsEmpty() { + #expect(request.headers.isEmpty) } - func testHeadersIsEmpty() { - XCTAssertTrue(request.headers.isEmpty) - } - - func testBodyIsNil() { - XCTAssertNil(request.body) + @Test("body is nil") + func bodyIsNil() { + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesImagesRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesImagesRequestTests.swift index 2d8f52bf..04a67be5 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesImagesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesImagesRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesImagesRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesImagesRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeriesImagesRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/images") + #expect(request.path == "/tv/1/images") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeriesImagesRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguages() { + @Test("queryItems with languages") + func queryItemsWithLanguages() { let request = TVSeriesImagesRequest(id: 1, languages: ["en-GB", "fr"]) - XCTAssertEqual(request.queryItems, ["include_image_language": "en,fr,null"]) + #expect(request.queryItems == ["include_image_language": "en,fr,null"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeriesImagesRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeriesImagesRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeriesImagesRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRecommendationsRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRecommendationsRequestTests.swift index 6ca84323..e22f4e54 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRecommendationsRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRecommendationsRequestTests.swift @@ -17,57 +17,67 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesRecommendationsRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesRecommendationsRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeriesRecommendationsRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/recommendations") + #expect(request.path == "/tv/1/recommendations") } - func testQueryItemsIsEmpty() { + @Test("queryItem is empty") + func queryItemsIsEmpty() { let request = TVSeriesRecommendationsRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithPage() { + @Test("queryItems with page") + func queryItemsWithPage() { let request = TVSeriesRecommendationsRequest(id: 1, page: 3) - XCTAssertEqual(request.queryItems, ["page": "3"]) + #expect(request.queryItems == ["page": "3"]) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = TVSeriesRecommendationsRequest(id: 1, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testQueryItemsWithPageAndLanguage() { + @Test("queryItems with page and language") + func queryItemsWithPageAndLanguage() { let request = TVSeriesRecommendationsRequest(id: 1, page: 3, language: "en") - XCTAssertEqual(request.queryItems, ["page": "3", "language": "en"]) + #expect(request.queryItems == ["page": "3", "language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeriesRecommendationsRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeriesRecommendationsRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeriesRecommendationsRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRequestTests.swift index 8a72a845..1975aa5c 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeriesRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1") + #expect(request.path == "/tv/1") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeriesRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = TVSeriesRequest(id: 1, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeriesRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeriesRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeriesRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesReviewsRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesReviewsRequestTests.swift index e4a7bd7c..ecc46e7d 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesReviewsRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesReviewsRequestTests.swift @@ -17,57 +17,67 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesReviewsRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesReviewsRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeriesReviewsRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/reviews") + #expect(request.path == "/tv/1/reviews") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeriesReviewsRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithPage() { + @Test("queryItems with page") + func queryItemsWithPage() { let request = TVSeriesReviewsRequest(id: 1, page: 3) - XCTAssertEqual(request.queryItems, ["page": "3"]) + #expect(request.queryItems == ["page": "3"]) } - func testQueryItemsWithLanguage() { + @Test("queryItems with language") + func queryItemsWithLanguage() { let request = TVSeriesReviewsRequest(id: 1, language: "en") - XCTAssertEqual(request.queryItems, ["language": "en"]) + #expect(request.queryItems == ["language": "en"]) } - func testQueryItemsWithPageAndLanguage() { + @Test("queryItems with page and language") + func queryItemsWithPageAndLanguage() { let request = TVSeriesReviewsRequest(id: 1, page: 2, language: "en") - XCTAssertEqual(request.queryItems, ["page": "2", "language": "en"]) + #expect(request.queryItems == ["page": "2", "language": "en"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeriesReviewsRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeriesReviewsRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeriesReviewsRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesVideosRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesVideosRequestTests.swift index b534d368..a2fd5aa2 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesVideosRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesVideosRequestTests.swift @@ -17,45 +17,53 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesVideosRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesVideosRequestTests { - func testPath() { + @Test("path is correct") + func path() { let request = TVSeriesVideosRequest(id: 1) - XCTAssertEqual(request.path, "/tv/1/videos") + #expect(request.path == "/tv/1/videos") } - func testQueryItemsIsEmpty() { + @Test("queryItems is empty") + func queryItemsIsEmpty() { let request = TVSeriesVideosRequest(id: 1) - XCTAssertTrue(request.queryItems.isEmpty) + #expect(request.queryItems.isEmpty) } - func testQueryItemsWithLanguages() { + @Test("queryItems with languages") + func queryItemsWithLanguages() { let request = TVSeriesVideosRequest(id: 1, languages: ["en-GB", "fr"]) - XCTAssertEqual(request.queryItems["include_video_language"], "en-GB,fr") + #expect(request.queryItems == ["include_video_language": "en-GB,fr"]) } - func testMethodIsGet() { + @Test("method is GET") + func methodIsGet() { let request = TVSeriesVideosRequest(id: 1) - XCTAssertEqual(request.method, .get) + #expect(request.method == .get) } - func testHeadersIsEmpty() { + @Test("headers is empty") + func headersIsEmpty() { let request = TVSeriesVideosRequest(id: 1) - XCTAssertTrue(request.headers.isEmpty) + #expect(request.headers.isEmpty) } - func testBodyIsNil() { + @Test("body is nil") + func bodyIsNil() { let request = TVSeriesVideosRequest(id: 1) - XCTAssertNil(request.body) + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesWatchProvidersRequestTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesWatchProvidersRequestTests.swift index 2ce9fe13..703f98a1 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesWatchProvidersRequestTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/Requests/TVSeriesWatchProvidersRequestTests.swift @@ -17,41 +17,42 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TVSeriesWatchProvidersRequestTests: XCTestCase { +@Suite(.tags(.requests, .tvSeries)) +struct TVSeriesWatchProvidersRequestTests { var request: TVSeriesWatchProvidersRequest! - override func setUp() { - super.setUp() - request = TVSeriesWatchProvidersRequest(id: 1) + init() { + self.request = TVSeriesWatchProvidersRequest(id: 1) } - override func tearDown() { - request = nil - super.tearDown() + @Test("path is correct") + func path() { + #expect(request.path == "/tv/1/watch/providers") } - func testPath() { - XCTAssertEqual(request.path, "/tv/1/watch/providers") + @Test("queryItems is empty") + func queryItemsIsEmpty() { + #expect(request.queryItems.isEmpty) } - func testQueryItemsIsEmpty() { - XCTAssertTrue(request.queryItems.isEmpty) + @Test("method is GET") + func methodIsGet() { + #expect(request.method == .get) } - func testMethodIsGet() { - XCTAssertEqual(request.method, .get) + @Test("headers is empty") + func headersIsEmpty() { + #expect(request.headers.isEmpty) } - func testHeadersIsEmpty() { - XCTAssertTrue(request.headers.isEmpty) - } - - func testBodyIsNil() { - XCTAssertNil(request.body) + @Test("body is nil") + func bodyIsNil() { + #expect(request.body == nil) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceContentRatingTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceContentRatingTests.swift index 0fccdf5b..e88d3924 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceContentRatingTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceContentRatingTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeriesServiceContentRatingTests: XCTestCase { +@Suite(.tags(.services, .tvSeries)) +struct TMDbTVSeriesServiceContentRatingTests { var service: TMDbTVSeriesService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeriesService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeriesService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testContentRatingsWithCountryReturnsShowRatings() async throws { + @Test("contentRatings with country returns TV series ratings") + func contentRatingsWithCountryReturnsTVSeriesRatings() async throws { let expectedResult = ContentRatingResult.mock let tvSeriesID = expectedResult.id let country = "US" @@ -51,23 +47,17 @@ final class TMDbTVSeriesServiceContentRatingTests: XCTestCase { let result = try await service.contentRatings(forTVSeries: tvSeriesID, country: country) - XCTAssertEqual(result, expectedRating) - XCTAssertEqual(apiClient.lastRequest as? ContentRatingRequest, expectedRequest) + #expect(result == expectedRating) + #expect(apiClient.lastRequest as? ContentRatingRequest == expectedRequest) } - func testContentRatingsWhenErrorsThrowsError() async throws { + @Test("contentRatings when errors throws error") + func contentRatingsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.contentRatings(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceCreditsTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceCreditsTests.swift index 0e9c07cc..e82f692d 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceCreditsTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceCreditsTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeriesServiceCreditsTests: XCTestCase { +@Suite(.tags(.services, .tvSeries)) +struct TMDbTVSeriesServiceCreditsTests { var service: TMDbTVSeriesService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeriesService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeriesService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testCreditsReturnsShowsCredits() async throws { + @Test("credits returns TV series credits") + func creditsReturnsTVSeriesCredits() async throws { let expectedResult = ShowCredits.mock() let tvSeriesID = expectedResult.id apiClient.addResponse(.success(expectedResult)) @@ -45,11 +41,12 @@ final class TMDbTVSeriesServiceCreditsTests: XCTestCase { let result = try await service.credits(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesCreditsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesCreditsRequest == expectedRequest) } - func testCreditsWithLanguageReturnsShowsCredits() async throws { + @Test("credits with language returns TV series credits") + func creditsWithLanguageReturnsTVSeriesCredits() async throws { let expectedResult = ShowCredits.mock() let tvSeriesID = expectedResult.id let language = "en" @@ -58,27 +55,22 @@ final class TMDbTVSeriesServiceCreditsTests: XCTestCase { let result = try await service.credits(forTVSeries: tvSeriesID, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesCreditsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesCreditsRequest == expectedRequest) } - func testCreditsWhenErrorsThrowsError() async throws { + @Test("credit when errors throws error") + func creditsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.credits(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testAggregateCreditsReturnsShowsCredits() async throws { + @Test("aggregateCredits returns TV series credits") + func aggregateCreditsReturnsTVSeriesCredits() async throws { let expectedResult = TVSeriesAggregateCredits(id: 1, cast: [], crew: []) let tvSeriesID = expectedResult.id apiClient.addResponse(.success(expectedResult)) @@ -86,11 +78,12 @@ final class TMDbTVSeriesServiceCreditsTests: XCTestCase { let result = try await service.aggregateCredits(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesAggregateCreditsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesAggregateCreditsRequest == expectedRequest) } - func testAggregateCreditsWithLanguageReturnsShowsCredits() async throws { + @Test("aggregateCredits with language returns TV series credits") + func aggregateCreditsWithLanguageReturnsTVSeriesCredits() async throws { let expectedResult = TVSeriesAggregateCredits(id: 1, cast: [], crew: []) let tvSeriesID = expectedResult.id let language = "en" @@ -99,24 +92,18 @@ final class TMDbTVSeriesServiceCreditsTests: XCTestCase { let result = try await service.aggregateCredits(forTVSeries: tvSeriesID, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesAggregateCreditsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesAggregateCreditsRequest == expectedRequest) } - func testAggregateCreditsWhenErrorsThrowsError() async throws { + @Test("aggregateCredits when errors throws error") + func aggregateCreditsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.aggregateCredits(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceDetailsTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceDetailsTests.swift index 8500eeb2..433b2608 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceDetailsTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceDetailsTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeriesServiceTests: XCTestCase { +@Suite(.tags(.services, .tvSeries)) +struct TMDbTVSeriesServiceTests { var service: TMDbTVSeriesService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeriesService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeriesService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testDetailsReturnsTVSeries() async throws { + @Test("details returns TV series") + func detailsReturnsTVSeries() async throws { let expectedResult = TVSeries.theSandman let tvSeriesID = expectedResult.id apiClient.addResponse(.success(expectedResult)) @@ -45,11 +41,12 @@ final class TMDbTVSeriesServiceTests: XCTestCase { let result = try await service.details(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesRequest == expectedRequest) } - func testDetailsWithLanguageReturnsTVSeries() async throws { + @Test("details with language returns TV series") + func detailsWithLanguageReturnsTVSeries() async throws { let expectedResult = TVSeries.theSandman let tvSeriesID = expectedResult.id let language = "en" @@ -58,24 +55,18 @@ final class TMDbTVSeriesServiceTests: XCTestCase { let result = try await service.details(forTVSeries: tvSeriesID, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesRequest == expectedRequest) } - func testDetailsWhenErrorsThrowsError() async throws { + @Test("details when errors throws error") + func detailsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.details(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift index 9941ffc7..312f181f 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceListsTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeriesServiceListsTests: XCTestCase { +@Suite(.tags(.services, .tvSeries)) +struct TMDbTVSeriesServiceListsTests { var service: TMDbTVSeriesService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeriesService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeriesService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testRecommendationsReturnsTVSeries() async throws { + @Test("recommenendations returns TV series") + func recommendationsReturnsTVSeries() async throws { let tvSeriesID = Int.randomID let expectedResult = TVSeriesPageableList.mock() apiClient.addResponse(.success(expectedResult)) @@ -45,11 +41,12 @@ final class TMDbTVSeriesServiceListsTests: XCTestCase { let result = try await service.recommendations(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesRecommendationsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesRecommendationsRequest == expectedRequest) } - func testRecommendationsWithPageAndLanguageReturnsTVSeries() async throws { + @Test("recommendations with page and language returns TV series") + func recommendationsWithPageAndLanguageReturnsTVSeries() async throws { let tvSeriesID = Int.randomID let page = 2 let language = "en" @@ -59,27 +56,22 @@ final class TMDbTVSeriesServiceListsTests: XCTestCase { let result = try await service.recommendations(forTVSeries: tvSeriesID, page: page, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesRecommendationsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesRecommendationsRequest == expectedRequest) } - func testRecommendationsWhenErrorsThrowsError() async throws { + @Test("recommendations when errors throws error") + func recommendationsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.recommendations(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testSimilarReturnsTVSeries() async throws { + @Test("similar returns TV series") + func similarReturnsTVSeries() async throws { let tvSeriesID = Int.randomID let expectedResult = TVSeriesPageableList.mock() apiClient.addResponse(.success(expectedResult)) @@ -87,11 +79,12 @@ final class TMDbTVSeriesServiceListsTests: XCTestCase { let result = try await service.similar(toTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? SimilarTVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? SimilarTVSeriesRequest == expectedRequest) } - func testSimilarWithPageAndLanguageReturnsTVSeries() async throws { + @Test("similar with page and language returns TV series") + func similarWithPageAndLanguageReturnsTVSeries() async throws { let tvSeriesID = Int.randomID let page = 2 let language = "en" @@ -101,38 +94,34 @@ final class TMDbTVSeriesServiceListsTests: XCTestCase { let result = try await service.similar(toTVSeries: tvSeriesID, page: page, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? SimilarTVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? SimilarTVSeriesRequest == expectedRequest) } - func testSimilarWhenErrorsThrowsError() async throws { + @Test("similar when errors throws error") + func similarWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.similar(toTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testPopularReturnsTVSeries() async throws { + @Test("popular returns TV series") + func popularReturnsTVSeries() async throws { let expectedResult = TVSeriesPageableList.mock() apiClient.addResponse(.success(expectedResult)) let expectedRequest = PopularTVSeriesRequest(page: nil, language: nil) let result = try await service.popular() - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? PopularTVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? PopularTVSeriesRequest == expectedRequest) } - func testPopularWithPageAndLanguageReturnsTVSeries() async throws { + @Test("popular with page and language returns TV series") + func popularWithPageAndLanguageReturnsTVSeries() async throws { let page = 2 let language = "en" let expectedResult = TVSeriesPageableList.mock() @@ -141,23 +130,17 @@ final class TMDbTVSeriesServiceListsTests: XCTestCase { let result = try await service.popular(page: page, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? PopularTVSeriesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? PopularTVSeriesRequest == expectedRequest) } - func testPopularWhenErrorsThrowsError() async throws { + @Test("popular when errors throws error") + func popularWhenErrorsThrowsError() async throws { apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.popular() - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift index 57b7d84b..30c694fa 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceMediaTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeriesServiceMediaTests: XCTestCase { +@Suite(.tags(.services, .tvSeries)) +struct TMDbTVSeriesServiceMediaTests { var service: TMDbTVSeriesService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeriesService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeriesService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testImagesReturnsImages() async throws { + @Test("images returns images") + func imagesReturnsImages() async throws { let tvSeriesID = Int.randomID let expectedResult = ImageCollection.mock() apiClient.addResponse(.success(expectedResult)) @@ -45,11 +41,12 @@ final class TMDbTVSeriesServiceMediaTests: XCTestCase { let result = try await service.images(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesImagesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesImagesRequest == expectedRequest) } - func testImagesWithFilterReturnsImages() async throws { + @Test("images with filter returns images") + func imagesWithFilterReturnsImages() async throws { let tvSeriesID = Int.randomID let languages = ["en-GB", "fr"] let expectedResult = ImageCollection.mock() @@ -59,27 +56,22 @@ final class TMDbTVSeriesServiceMediaTests: XCTestCase { let filter = TVSeriesImageFilter(languages: languages) let result = try await service.images(forTVSeries: tvSeriesID, filter: filter) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesImagesRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesImagesRequest == expectedRequest) } - func testImagesWhenErrorsThrowsError() async throws { + @Test("images when errors throws error") + func imagesWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.images(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testVideosReturnsVideos() async throws { + @Test("video returns videos") + func videosReturnsVideos() async throws { let expectedResult = VideoCollection.mock() let tvSeriesID = expectedResult.id apiClient.addResponse(.success(expectedResult)) @@ -87,11 +79,12 @@ final class TMDbTVSeriesServiceMediaTests: XCTestCase { let result = try await service.videos(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesVideosRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesVideosRequest == expectedRequest) } - func testVideosWithFilterReturnsVideos() async throws { + @Test("videos with filter returns videos") + func videosWithFilterReturnsVideos() async throws { let expectedResult = VideoCollection.mock() let tvSeriesID = expectedResult.id let languages = ["en", "fr"] @@ -101,24 +94,18 @@ final class TMDbTVSeriesServiceMediaTests: XCTestCase { let filter = TVSeriesVideoFilter(languages: languages) let result = try await service.videos(forTVSeries: tvSeriesID, filter: filter) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesVideosRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesVideosRequest == expectedRequest) } - func testVideosWhenErrorsThrowsError() async throws { + @Test("video when errors throws error") + func videosWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.videos(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceOthersTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceOthersTests.swift index 2ceb22ca..f4ce6c5b 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceOthersTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceOthersTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeriesServiceOthersTests: XCTestCase { +@Suite(.tags(.services, .tvSeries)) +struct TMDbTVSeriesServiceOthersTests { var service: TMDbTVSeriesService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeriesService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeriesService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testWatchProvidersReturnsWatchProviders() async throws { + @Test("watchProviders returns watch providers") + func watchProvidersReturnsWatchProviders() async throws { let expectedResult = ShowWatchProviderResult.mock() let tvSeriesID = 1 let country = "GB" @@ -46,27 +42,22 @@ final class TMDbTVSeriesServiceOthersTests: XCTestCase { let result = try await service.watchProviders(forTVSeries: tvSeriesID, country: country) - XCTAssertEqual(result, expectedResult.results[country]) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesWatchProvidersRequest, expectedRequest) + #expect(result == expectedResult.results[country]) + #expect(apiClient.lastRequest as? TVSeriesWatchProvidersRequest == expectedRequest) } - func testWatchProvidersWhenErrorsThrowsError() async throws { + @Test("watchProviders when errors throws error") + func watchProvidersWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.watchProviders(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } - func testExternalLinksReturnsExternalLinks() async throws { + @Test("externalLinks returns external links") + func externalLinksReturnsExternalLinks() async throws { let expectedResult = TVSeriesExternalLinksCollection.lockeAndKey let tvSeriesID = 86423 apiClient.addResponse(.success(expectedResult)) @@ -74,24 +65,18 @@ final class TMDbTVSeriesServiceOthersTests: XCTestCase { let result = try await service.externalLinks(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesExternalLinksRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesExternalLinksRequest == expectedRequest) } - func testExternalLinksWhenErrorsThrowsError() async throws { + @Test("externalLinks when errors throws error") + func externalLinksWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.externalLinks(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift index b24537d4..ef5c1831 100644 --- a/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift +++ b/Tests/TMDbTests/Domain/Services/TVSeries/TMDbTVSeriesServiceReviewsTests.swift @@ -17,27 +17,23 @@ // limitations under the License. // +import Foundation +import Testing @testable import TMDb -import XCTest -final class TMDbTVSeriesServiceReviewsTests: XCTestCase { +@Suite(.tags(.services, .tvSeries)) +struct TMDbTVSeriesServiceReviewsTests { var service: TMDbTVSeriesService! var apiClient: MockAPIClient! - override func setUp() { - super.setUp() - apiClient = MockAPIClient() - service = TMDbTVSeriesService(apiClient: apiClient) + init() { + self.apiClient = MockAPIClient() + self.service = TMDbTVSeriesService(apiClient: apiClient) } - override func tearDown() { - apiClient = nil - service = nil - super.tearDown() - } - - func testReviewsReturnsReviews() async throws { + @Test("reviews returns reviews") + func reviewsReturnsReviews() async throws { let tvSeriesID = Int.randomID let expectedResult = ReviewPageableList.mock() apiClient.addResponse(.success(expectedResult)) @@ -45,11 +41,12 @@ final class TMDbTVSeriesServiceReviewsTests: XCTestCase { let result = try await service.reviews(forTVSeries: tvSeriesID) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesReviewsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesReviewsRequest == expectedRequest) } - func testReviewsWithLanguageReturnsReviews() async throws { + @Test("reviews with language returns reviews") + func reviewsWithLanguageReturnsReviews() async throws { let tvSeriesID = Int.randomID let language = "en" let expectedResult = ReviewPageableList.mock() @@ -58,24 +55,18 @@ final class TMDbTVSeriesServiceReviewsTests: XCTestCase { let result = try await service.reviews(forTVSeries: tvSeriesID, language: language) - XCTAssertEqual(result, expectedResult) - XCTAssertEqual(apiClient.lastRequest as? TVSeriesReviewsRequest, expectedRequest) + #expect(result == expectedResult) + #expect(apiClient.lastRequest as? TVSeriesReviewsRequest == expectedRequest) } - func testReviewsWhenErrorsThrowsError() async throws { + @Test("reviews when errors returns error") + func reviewsWhenErrorsThrowsError() async throws { let tvSeriesID = 1 apiClient.addResponse(.failure(.unknown)) - var error: Error? - do { + await #expect(throws: TMDbError.unknown) { _ = try await service.reviews(forTVSeries: tvSeriesID) - } catch let err { - error = err } - - let tmdbAPIError = try XCTUnwrap(error as? TMDbError) - - XCTAssertEqual(tmdbAPIError, .unknown) } } diff --git a/Tests/TMDbTests/TestUtils/Tags.swift b/Tests/TMDbTests/TestUtils/Tags.swift index 0f1de86e..d885d2e2 100644 --- a/Tests/TMDbTests/TestUtils/Tags.swift +++ b/Tests/TMDbTests/TestUtils/Tags.swift @@ -44,5 +44,8 @@ extension Tag { @Tag static var search: Self @Tag static var trending: Self @Tag static var tvEpisode: Self + @Tag static var tvSeason: Self + @Tag static var tvSeries: Self + @Tag static var watchProvider: Self }