-
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.
Merge pull request #213 from YAPP-Github/Test/#212
Test/#212 DTO Tests
- Loading branch information
Showing
16 changed files
with
372 additions
and
289 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
19 changes: 0 additions & 19 deletions
19
RefillStation/RefillStation/Domain/Interfaces/Repositories/AccountRepositoryInterface.swift
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...efillStation/Domain/Interfaces/Repositories/CustomerSatisfactionRepositoryInterface.swift
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...tion/RefillStation/Domain/Interfaces/Repositories/RegisterReviewRepositoryInterface.swift
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
RefillStation/RefillStation/Domain/Interfaces/Repositories/StoreRepositoryInterface.swift
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
RefillStation/RefillStation/Domain/Interfaces/Repositories/UserInfoRepositoryInterface.swift
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
RefillStation/RefillStationTests/DTOTests/Account/LoginDTOTests.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,42 @@ | ||
// | ||
// LoginDTOTests.swift | ||
// RefillStationTests | ||
// | ||
// Created by 천수현 on 2023/02/22. | ||
// | ||
|
||
import XCTest | ||
@testable import RefillStation | ||
|
||
final class LoginDTOTests: XCTestCase { | ||
var fullContentUnit: LoginDTO! | ||
var minimumContentUnit: LoginDTO! | ||
|
||
override func setUpWithError() throws { | ||
fullContentUnit = LoginDTO(name: "name", email: "email", imgPath: "imgPath", oauthType: "oauthType", oauthIdentity: "oauthIdentity", jwt: "jwt", refreshToken: "refreshToken") | ||
minimumContentUnit = LoginDTO(name: nil, email: nil, imgPath: nil, oauthType: nil, oauthIdentity: nil, jwt: nil, refreshToken: nil) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
fullContentUnit = nil | ||
minimumContentUnit = nil | ||
} | ||
|
||
func test_모든_필드가_채워진_LoginDTO의_toDomain_메서드를_호출하면_모든_필드가_채워진_OAuthLoginResponseValue를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = fullContentUnit.toDomain() | ||
// then | ||
let expectationResult = OAuthLoginResponseValue(name: "name", email: "email", imgPath: "imgPath", oauthIdentity: "oauthIdentity", oauthType: "oauthType", jwt: "jwt", refreshToken: "refreshToken") | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
|
||
func test_최소한의_필드만_채워진_LoginDTO의_toDomain_메서드를_호출하면_기본값으로_채워진_OAuthLoginResponseValue를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = minimumContentUnit.toDomain() | ||
// then | ||
let expectationResult = OAuthLoginResponseValue(name: nil, email: nil, imgPath: nil, oauthIdentity: "", oauthType: "", jwt: nil, refreshToken: "") | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
} |
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) | ||
} | ||
} | ||
|
43 changes: 43 additions & 0 deletions
43
RefillStation/RefillStationTests/DTOTests/Store/ProductDTOTests.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 @@ | ||
// | ||
// ProductDTOTests.swift | ||
// RefillStationTests | ||
// | ||
// Created by 천수현 on 2023/02/23. | ||
// | ||
|
||
import XCTest | ||
@testable import RefillStation | ||
|
||
final class ProductDTOTests: XCTestCase { | ||
var fullContentUnit: ProductDTO! | ||
var minimumContentUnit: ProductDTO! | ||
|
||
override func setUpWithError() throws { | ||
fullContentUnit = ProductDTO(createdAt: "", modifiedAt: "", id: 0, storeId: 0, title: "title", price: 10, unit: "mg", brand: "brand", category: "샴푸", imgPath: "imgPath", isHided: true, isReady: true) | ||
|
||
minimumContentUnit = ProductDTO(createdAt: nil, modifiedAt: nil, id: nil, storeId: nil, title: nil, price: nil, unit: nil, brand: nil, category: nil, imgPath: nil, isHided: nil, isReady: nil) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
fullContentUnit = nil | ||
minimumContentUnit = nil | ||
} | ||
|
||
func test_모든_필드가_채워진_ProductDTO의_toDomain_메서드를_호출하면_모든_필드가_채워진_Product를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = fullContentUnit.toDomain() | ||
// then | ||
let expectationResult = Product(name: "title", brand: "brand", measurement: "mg", price: 10, imageURL: "imgPath", category: .init(title: "샴푸")) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
|
||
func test_최소한의_필드만_채워진_ProductDTO의_toDomain_메서드를_호출하면_기본값으로_채워진_Product를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = minimumContentUnit.toDomain() | ||
// then | ||
let expectationResult = Product(name: "", brand: "", measurement: "", price: 0, imageURL: "", category: .init(title: "")) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
} |
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 | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
RefillStation/RefillStationTests/DTOTests/Store/StoreDTOTests.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 @@ | ||
// | ||
// StoreDTOTests.swift | ||
// RefillStationTests | ||
// | ||
// Created by 천수현 on 2023/02/23. | ||
// | ||
|
||
import XCTest | ||
@testable import RefillStation | ||
|
||
final class StoreDTOTests: XCTestCase { | ||
var fullContentUnit: StoreDTO! | ||
var minimumContentUnit: StoreDTO! | ||
|
||
override func setUpWithError() throws { | ||
fullContentUnit = StoreDTO(id: 0, userId: 0, name: "name", status: "", longitude: "", latitude: "", businessHour: [.init(day: "월월", time: "test time")], notice: "", address: "address", instaAccount: "instaAccount", callNumber: "", registrationNumber: "", isReady: true, distance: "10", imgStores: [.init(id: 0, storeId: 0, path: "")], storeRefillGuides: [.init(createdAt: "", modifiedAt: "", id: 0, storeId: 0, imgPath: "", removedAt: "")]) | ||
|
||
minimumContentUnit = StoreDTO(id: nil, userId: nil, name: nil, status: nil, longitude: nil, latitude: nil, businessHour: nil, notice: nil, address: nil, instaAccount: nil, callNumber: nil, registrationNumber: nil, isReady: nil, distance: nil, imgStores: [], storeRefillGuides: []) | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
fullContentUnit = nil | ||
minimumContentUnit = nil | ||
} | ||
|
||
func test_모든_필드가_채워진_StoreDTO의_toDomain_메서드를_호출하면_모든_필드가_채워진_Store를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = fullContentUnit.toDomain() | ||
// then | ||
let expectationResult = Store(storeId: 0, name: "name", address: "address", distance: 10, phoneNumber: "", snsAddress: "instaAccount", didUserRecommended: false, recommendedCount: 0, imageURL: [""], businessHour: [.init(day: .mon, time: "test time")], notice: "", storeRefillGuideImagePaths: [""]) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
|
||
func test_최소한의_필드만_채워진_StoreDTO의_toDomain_메서드를_호출하면_기본값으로_채워진_Store를_반환하는지() { | ||
// given | ||
// when | ||
let domainResult = minimumContentUnit.toDomain() | ||
// then | ||
let expectationResult = Store(storeId: 0, name: "", address: "", distance: 0, phoneNumber: "", snsAddress: "", didUserRecommended: false, recommendedCount: 0, imageURL: [], businessHour: [], notice: "", storeRefillGuideImagePaths: []) | ||
XCTAssertEqual(domainResult, expectationResult) | ||
} | ||
} | ||
|
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) | ||
} | ||
} |
Oops, something went wrong.