-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
211 additions
and
5 deletions.
There are no files selected for viewing
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
44 changes: 44 additions & 0 deletions
44
RefillStation/RefillStationTests/DTOTests/Store/FetchStoreRecommendDTOTests.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// FetchStoreRecommendTests.swift | ||
// RefillStationTests | ||
// | ||
// Created by 천수현 on 2023/02/23. | ||
// | ||
|
||
import XCTest | ||
@testable import RefillStation | ||
|
||
final class FetchStoreRecommendDTOTests: XCTestCase { | ||
var fullContentUnit: FetchStoreRecommendDTO! | ||
var minimumContentUnit: FetchStoreRecommendDTO! | ||
|
||
override func setUpWithError() throws { | ||
fullContentUnit = FetchStoreRecommendDTO(recommendation: true, count: 10) | ||
|
||
minimumContentUnit = FetchStoreRecommendDTO(recommendation: nil, count: nil) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
fullContentUnit = nil | ||
minimumContentUnit = nil | ||
} | ||
|
||
func test_모든_필드가_채워진_FetchStoreRecommendDTO의_toDomain_메서드를_호출하면_모든_필드가_채워진_FetchStoreRecommendResponseValue를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = fullContentUnit.toResponseValue() | ||
// then | ||
let expectationResult = FetchStoreRecommendResponseValue(recommendCount: 10, didRecommended: true) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
|
||
func test_최소한의_필드만_채워진_FetchStoreRecommendDTO의_toDomain_메서드를_호출하면_기본값으로_채워진_FetchStoreRecommendResponseValue를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = minimumContentUnit.toResponseValue() | ||
// then | ||
let expectationResult = FetchStoreRecommendResponseValue(recommendCount: 0, didRecommended: false) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
} | ||
|
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
52 changes: 52 additions & 0 deletions
52
RefillStation/RefillStationTests/DTOTests/Store/ReviewDTOTests.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// ReviewDTOTests.swift | ||
// RefillStationTests | ||
// | ||
// Created by 천수현 on 2023/02/23. | ||
// | ||
|
||
import XCTest | ||
@testable import RefillStation | ||
|
||
final class ReviewDTOTests: XCTestCase { | ||
var fullContentUnit: ReviewDTO! | ||
var minimumContentUnit: ReviewDTO! | ||
|
||
override func setUpWithError() throws { | ||
fullContentUnit = ReviewDTO(id: 1, storeId: 1, userId: 1, reviewText: "reviewText", createdAt: "2023-01-29T18:56:24", modifiedAt: "modifiedAt", user: .init(createdAt: "createdAt", modifiedAt: "modifiedAt", id: 1, name: "name", nickname: "nickname", email: "email", phoneNumber: "phoneNumber", type: "type", oauthType: "oauthType", oauthIdentity: "oauthIdentity", rating: 1, imgPath: "imgPath", removedAt: "removedAt"), imgReviews: [.init(createdAt: "createdAt", modifiedAt: "modifiedAt", id: 1, reviewId: 1, path: "path")], reviewTagLogs: [.init(createdAt: "createdAt", modifiedAt: "modifiedAt", id: 1, reviewId: 1, userId: 1, storeId: 1, reviewTagId: -1), .init(createdAt: "createdAt", modifiedAt: "modifiedAt", id: 1, reviewId: 1, userId: 1, storeId: 1, reviewTagId: nil)]) | ||
|
||
minimumContentUnit = ReviewDTO(id: nil, storeId: nil, userId: nil, reviewText: nil, createdAt: "2023-01-29T18:56:24", modifiedAt: nil, user: nil, imgReviews: nil, reviewTagLogs: nil) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
fullContentUnit = nil | ||
minimumContentUnit = nil | ||
} | ||
|
||
func test_모든_필드가_채워진_ReviewDTO의_toDomain_메서드를_호출하면_모든_필드가_채워진_Review를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = fullContentUnit.toDomain() | ||
// then | ||
let expectationResult = Review(userId: 1, userNickname: "nickname", profileImagePath: "imgPath", writtenDate: "2023-01-29T18:56:24".toDate()!, imageURL: ["path"], description: "reviewText", tags: [.noKeywordToChoose, .noKeywordToChoose]) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
|
||
func test_최소한의_필드만_채워진_ReviewDTO의_toDomain_메서드를_호출하면_기본값으로_채워진_Review를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = minimumContentUnit.toDomain() | ||
// then | ||
let expectationResult = Review(userId: 0, userNickname: "", profileImagePath: "", writtenDate: "2023-01-29T18:56:24".toDate()!, imageURL: [], description: "", tags: []) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
} | ||
|
||
fileprivate extension String { | ||
func toDate() -> Date? { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" // "2023-02-07T14:22:26" | ||
let dateString = dateFormatter.date(from: self) | ||
return dateString | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
RefillStation/RefillStationTests/DTOTests/Store/StoreRecommendDTOTests.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// StoreRecommendDTOTests.swift | ||
// RefillStationTests | ||
// | ||
// Created by 천수현 on 2023/02/23. | ||
// | ||
|
||
import XCTest | ||
@testable import RefillStation | ||
|
||
final class StoreRecommendDTOTests: XCTestCase { | ||
var fullContentUnit: StoreRecommendDTO! | ||
var minimumContentUnit: StoreRecommendDTO! | ||
|
||
override func setUpWithError() throws { | ||
fullContentUnit = StoreRecommendDTO(isRecommendation: true, count: 10) | ||
|
||
minimumContentUnit = StoreRecommendDTO(isRecommendation: nil, count: nil) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
fullContentUnit = nil | ||
minimumContentUnit = nil | ||
} | ||
|
||
func test_모든_필드가_채워진_StoreRecommendDTO의_toDomain_메서드를_호출하면_모든_필드가_채워진_RecommendStoreResponseValue를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = fullContentUnit.toResponseValue() | ||
// then | ||
let expectationResult = RecommendStoreResponseValue(recommendCount: 10, didRecommended: true) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
|
||
func test_최소한의_필드만_채워진_StoreRecommendDTO의_toDomain_메서드를_호출하면_기본값으로_채워진_RecommendStoreResponseValue를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = minimumContentUnit.toResponseValue() | ||
// then | ||
let expectationResult = RecommendStoreResponseValue(recommendCount: 0, didRecommended: false) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
RefillStation/RefillStationTests/DTOTests/User/UserDTOTests.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// UserDTOTests.swift | ||
// RefillStationTests | ||
// | ||
// Created by 천수현 on 2023/02/23. | ||
// | ||
|
||
import XCTest | ||
@testable import RefillStation | ||
|
||
final class UserDTOTests: XCTestCase { | ||
var fullContentUnit: UserDTO! | ||
var minimumContentUnit: UserDTO! | ||
|
||
override func setUpWithError() throws { | ||
fullContentUnit = UserDTO(createdAt: "createdAt", modifiedAt: "modifiedAt", id: 1, name: "name", nickname: "nickname", email: "email", phoneNumber: "phoneNumber", type: "type", oauthType: "oauthType", oauthIdentity: "oauthIdentity", rating: 2, imgPath: "imgPath") | ||
minimumContentUnit = UserDTO(createdAt: nil, modifiedAt: nil, id: nil, name: nil, nickname: nil, email: nil, phoneNumber: nil, type: nil, oauthType: nil, oauthIdentity: nil, rating: nil, imgPath: nil) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
fullContentUnit = nil | ||
minimumContentUnit = nil | ||
} | ||
|
||
func test_모든_필드가_채워진_UserDTO의_toDomain_메서드를_호출하면_모든_필드가_채워진_User를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = fullContentUnit.toDomain() | ||
// then | ||
let expectationResult = User(id: 1, name: "nickname", imageURL: "imgPath", level: .init(level: .beginner)) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
|
||
func test_최소한의_필드만_채워진_UserDTO의_toDomain_메서드를_호출하면_기본값으로_채워진_User를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = minimumContentUnit.toDomain() | ||
// then | ||
let expectationResult = User(id: 0, name: "", imageURL: nil, level: .init(level: .regular)) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
} | ||
|