From 0435bd1a22f90218ee49016c0edfd49bca549bc6 Mon Sep 17 00:00:00 2001 From: baegteun Date: Tue, 4 Jul 2023 14:30:41 +0900 Subject: [PATCH 1/5] :sparkles: :: LoadCurrentUserRoleUseCase --- .../Interface/DataSource/LocalUserDataSource.swift | 5 +++++ .../UserDomain/Interface/{ => Enums}/UserRoleType.swift | 0 .../UserDomain/Interface/Repository/UserRepository.swift | 5 +++++ .../Interface/UseCase/LoadCurrentUserRoleUseCase.swift | 5 +++++ 4 files changed, 15 insertions(+) create mode 100644 Projects/Domain/UserDomain/Interface/DataSource/LocalUserDataSource.swift rename Projects/Domain/UserDomain/Interface/{ => Enums}/UserRoleType.swift (100%) create mode 100644 Projects/Domain/UserDomain/Interface/Repository/UserRepository.swift create mode 100644 Projects/Domain/UserDomain/Interface/UseCase/LoadCurrentUserRoleUseCase.swift diff --git a/Projects/Domain/UserDomain/Interface/DataSource/LocalUserDataSource.swift b/Projects/Domain/UserDomain/Interface/DataSource/LocalUserDataSource.swift new file mode 100644 index 00000000..b5c8b013 --- /dev/null +++ b/Projects/Domain/UserDomain/Interface/DataSource/LocalUserDataSource.swift @@ -0,0 +1,5 @@ +import Foundation + +public protocol LocalUserDataSource { + func loadCurrentUserRole() throws -> UserRoleType +} diff --git a/Projects/Domain/UserDomain/Interface/UserRoleType.swift b/Projects/Domain/UserDomain/Interface/Enums/UserRoleType.swift similarity index 100% rename from Projects/Domain/UserDomain/Interface/UserRoleType.swift rename to Projects/Domain/UserDomain/Interface/Enums/UserRoleType.swift diff --git a/Projects/Domain/UserDomain/Interface/Repository/UserRepository.swift b/Projects/Domain/UserDomain/Interface/Repository/UserRepository.swift new file mode 100644 index 00000000..517d70e7 --- /dev/null +++ b/Projects/Domain/UserDomain/Interface/Repository/UserRepository.swift @@ -0,0 +1,5 @@ +import Foundation + +public protocol UserRepository { + func loadCurrentUserRole() throws -> UserRoleType +} diff --git a/Projects/Domain/UserDomain/Interface/UseCase/LoadCurrentUserRoleUseCase.swift b/Projects/Domain/UserDomain/Interface/UseCase/LoadCurrentUserRoleUseCase.swift new file mode 100644 index 00000000..c4c24103 --- /dev/null +++ b/Projects/Domain/UserDomain/Interface/UseCase/LoadCurrentUserRoleUseCase.swift @@ -0,0 +1,5 @@ +import Foundation + +public protocol LoadCurrentUserRoleUseCase { + func callAsFunction() throws -> UserRoleType +} From 03ec4f039242de82ea28ba96f9c7e8f7fc7f3698 Mon Sep 17 00:00:00 2001 From: baegteun Date: Tue, 4 Jul 2023 14:45:45 +0900 Subject: [PATCH 2/5] =?UTF-8?q?:sparkles:=20::=20UserDomain=20Impl,=20Test?= =?UTF-8?q?ing=20=EA=B0=9D=EC=B2=B4=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interface/Error/UserDomainError.swift | 6 ++++++ Projects/Domain/UserDomain/Project.swift | 3 ++- .../DataSource/LocalUserDataSourceImpl.swift | 20 +++++++++++++++++++ .../Error/UserDomainErrorDescription.swift | 11 ++++++++++ .../Repository/UserRepositoryImpl.swift | 14 +++++++++++++ .../Domain/UserDomain/Sources/Source.swift | 1 - .../LoadCurrentUserRoleUseCaseImpl.swift | 14 +++++++++++++ .../DataSource/LocalUserDataSourceSpy.swift | 11 ++++++++++ .../Repository/UserRepositorySpy.swift | 11 ++++++++++ .../Domain/UserDomain/Testing/Testing.swift | 1 - .../LoadCurrentUserRoleUseCaseSpy.swift | 10 ++++++++++ 11 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 Projects/Domain/UserDomain/Interface/Error/UserDomainError.swift create mode 100644 Projects/Domain/UserDomain/Sources/DataSource/LocalUserDataSourceImpl.swift create mode 100644 Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift create mode 100644 Projects/Domain/UserDomain/Sources/Repository/UserRepositoryImpl.swift delete mode 100644 Projects/Domain/UserDomain/Sources/Source.swift create mode 100644 Projects/Domain/UserDomain/Sources/UseCase/LoadCurrentUserRoleUseCaseImpl.swift create mode 100644 Projects/Domain/UserDomain/Testing/DataSource/LocalUserDataSourceSpy.swift create mode 100644 Projects/Domain/UserDomain/Testing/Repository/UserRepositorySpy.swift delete mode 100644 Projects/Domain/UserDomain/Testing/Testing.swift create mode 100644 Projects/Domain/UserDomain/Testing/UseCase/LoadCurrentUserRoleUseCaseSpy.swift diff --git a/Projects/Domain/UserDomain/Interface/Error/UserDomainError.swift b/Projects/Domain/UserDomain/Interface/Error/UserDomainError.swift new file mode 100644 index 00000000..65e5e8bc --- /dev/null +++ b/Projects/Domain/UserDomain/Interface/Error/UserDomainError.swift @@ -0,0 +1,6 @@ +import Foundation + +public enum UserDomainError: Error { + // MARK: LoadCurrentUserRole + case cannotFindUserRole +} diff --git a/Projects/Domain/UserDomain/Project.swift b/Projects/Domain/UserDomain/Project.swift index b9e2d90b..678f05ab 100644 --- a/Projects/Domain/UserDomain/Project.swift +++ b/Projects/Domain/UserDomain/Project.swift @@ -8,7 +8,8 @@ let project = Project.module( .interface(module: .domain(.UserDomain)), .implements(module: .domain(.UserDomain), dependencies: [ .domain(target: .UserDomain, type: .interface), - .domain(target: .BaseDomain) + .domain(target: .BaseDomain), + .core(target: .KeyValueStore, type: .interface) ]), .testing(module: .domain(.UserDomain), dependencies: [ .domain(target: .UserDomain, type: .interface) diff --git a/Projects/Domain/UserDomain/Sources/DataSource/LocalUserDataSourceImpl.swift b/Projects/Domain/UserDomain/Sources/DataSource/LocalUserDataSourceImpl.swift new file mode 100644 index 00000000..c5f7354a --- /dev/null +++ b/Projects/Domain/UserDomain/Sources/DataSource/LocalUserDataSourceImpl.swift @@ -0,0 +1,20 @@ +import Foundation +import KeyValueStoreInterface +import UserDomainInterface + +final class LocalUserDataSourceImpl: LocalUserDataSource { + private let keyValueStore: any KeyValueStore + + init(keyValueStore: any KeyValueStore) { + self.keyValueStore = keyValueStore + } + + func loadCurrentUserRole() throws -> UserRoleType { + guard let userRoleString = keyValueStore.load(key: .userRole) as? String, + let userRole = UserRoleType(rawValue: userRoleString) + else { + throw UserDomainError.cannotFindUserRole + } + return userRole + } +} diff --git a/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift b/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift new file mode 100644 index 00000000..9458197c --- /dev/null +++ b/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift @@ -0,0 +1,11 @@ +import Foundation +import Localization + +extension UserDomainError: LocalizedError { + public var errorDescription: String? { + switch self { + case .cannotFindUserRole: + return "유저의 권한을 찾을 수 없습니다. 다시 로그인해주세요." + } + } +} diff --git a/Projects/Domain/UserDomain/Sources/Repository/UserRepositoryImpl.swift b/Projects/Domain/UserDomain/Sources/Repository/UserRepositoryImpl.swift new file mode 100644 index 00000000..8bb18dea --- /dev/null +++ b/Projects/Domain/UserDomain/Sources/Repository/UserRepositoryImpl.swift @@ -0,0 +1,14 @@ +import Foundation +import UserDomainInterface + +final class UserRepositoryImpl: UserRepository { + private let localUserDataSource: any LocalUserDataSource + + init(localUserDataSource: any LocalUserDataSource) { + self.localUserDataSource = localUserDataSource + } + + func loadCurrentUserRole() throws -> UserRoleType { + try localUserDataSource.loadCurrentUserRole() + } +} diff --git a/Projects/Domain/UserDomain/Sources/Source.swift b/Projects/Domain/UserDomain/Sources/Source.swift deleted file mode 100644 index b1853ce6..00000000 --- a/Projects/Domain/UserDomain/Sources/Source.swift +++ /dev/null @@ -1 +0,0 @@ -// This is for Tuist diff --git a/Projects/Domain/UserDomain/Sources/UseCase/LoadCurrentUserRoleUseCaseImpl.swift b/Projects/Domain/UserDomain/Sources/UseCase/LoadCurrentUserRoleUseCaseImpl.swift new file mode 100644 index 00000000..33096200 --- /dev/null +++ b/Projects/Domain/UserDomain/Sources/UseCase/LoadCurrentUserRoleUseCaseImpl.swift @@ -0,0 +1,14 @@ +import Foundation +import UserDomainInterface + +struct LoadCurrentUserRoleUseCaseImpl: LoadCurrentUserRoleUseCase { + private let userRepository: any UserRepository + + init(userRepository: any UserRepository){ + self.userRepository = userRepository + } + + func callAsFunction() throws -> UserRoleType { + try userRepository.loadCurrentUserRole() + } +} diff --git a/Projects/Domain/UserDomain/Testing/DataSource/LocalUserDataSourceSpy.swift b/Projects/Domain/UserDomain/Testing/DataSource/LocalUserDataSourceSpy.swift new file mode 100644 index 00000000..6a4849a2 --- /dev/null +++ b/Projects/Domain/UserDomain/Testing/DataSource/LocalUserDataSourceSpy.swift @@ -0,0 +1,11 @@ +import Foundation +import UserDomainInterface + +final class LocalUserDataSourceSpy: LocalUserDataSource { + var loadCurrentUserRoleCallCount = 0 + var loadCurrentUserRoleReturn: UserRoleType = .member + func loadCurrentUserRole() throws -> UserRoleType { + loadCurrentUserRoleCallCount += 1 + return loadCurrentUserRoleReturn + } +} diff --git a/Projects/Domain/UserDomain/Testing/Repository/UserRepositorySpy.swift b/Projects/Domain/UserDomain/Testing/Repository/UserRepositorySpy.swift new file mode 100644 index 00000000..844d5d16 --- /dev/null +++ b/Projects/Domain/UserDomain/Testing/Repository/UserRepositorySpy.swift @@ -0,0 +1,11 @@ +import Foundation +import UserDomainInterface + +final class UserRepositorySpy: UserRepository { + var loadCurrentUserRoleCallCount = 0 + var loadCurrentUserRoleReturn: UserRoleType = .member + func loadCurrentUserRole() throws -> UserRoleType { + loadCurrentUserRoleCallCount += 1 + return loadCurrentUserRoleReturn + } +} diff --git a/Projects/Domain/UserDomain/Testing/Testing.swift b/Projects/Domain/UserDomain/Testing/Testing.swift deleted file mode 100644 index b1853ce6..00000000 --- a/Projects/Domain/UserDomain/Testing/Testing.swift +++ /dev/null @@ -1 +0,0 @@ -// This is for Tuist diff --git a/Projects/Domain/UserDomain/Testing/UseCase/LoadCurrentUserRoleUseCaseSpy.swift b/Projects/Domain/UserDomain/Testing/UseCase/LoadCurrentUserRoleUseCaseSpy.swift new file mode 100644 index 00000000..d87e7699 --- /dev/null +++ b/Projects/Domain/UserDomain/Testing/UseCase/LoadCurrentUserRoleUseCaseSpy.swift @@ -0,0 +1,10 @@ +import UserDomainInterface + +final class LoadCurrentUserRoleUseCaseSpy: LoadCurrentUserRoleUseCase { + var loadCurrentUserRoleCallCount = 0 + var loadCurrentUserRoleReturn: UserRoleType = .member + func callAsFunction() throws -> UserRoleType { + loadCurrentUserRoleCallCount += 1 + return loadCurrentUserRoleReturn + } +} From 18525bafee9c09e96ffd5945c74c1398d05be5bf Mon Sep 17 00:00:00 2001 From: baegteun Date: Tue, 4 Jul 2023 15:05:25 +0900 Subject: [PATCH 3/5] =?UTF-8?q?:white=5Fcheck=5Fmark:=20::=20LocalUserData?= =?UTF-8?q?Source,=20UserRepository,=20LoadCurrentUserRoleUseCase=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Domain/UserDomain/Project.swift | 4 +- .../Error/UserDomainErrorDescription.swift | 1 + .../LoadCurrentUserRoleUseCaseTests.swift | 44 ++++++++++++++ .../Tests/LocalUserDataSourceTests.swift | 58 +++++++++++++++++++ .../UserDomain/Tests/UserDomainTest.swift | 11 ---- .../UserDomain/Tests/UserRepositoryTest.swift | 44 ++++++++++++++ .../Sources/CheckBox/DotoriCheckBox.swift | 4 +- 7 files changed, 152 insertions(+), 14 deletions(-) create mode 100644 Projects/Domain/UserDomain/Tests/LoadCurrentUserRoleUseCaseTests.swift create mode 100644 Projects/Domain/UserDomain/Tests/LocalUserDataSourceTests.swift delete mode 100644 Projects/Domain/UserDomain/Tests/UserDomainTest.swift create mode 100644 Projects/Domain/UserDomain/Tests/UserRepositoryTest.swift diff --git a/Projects/Domain/UserDomain/Project.swift b/Projects/Domain/UserDomain/Project.swift index 678f05ab..560e486b 100644 --- a/Projects/Domain/UserDomain/Project.swift +++ b/Projects/Domain/UserDomain/Project.swift @@ -15,7 +15,9 @@ let project = Project.module( .domain(target: .UserDomain, type: .interface) ]), .tests(module: .domain(.UserDomain), dependencies: [ - .domain(target: .UserDomain) + .domain(target: .UserDomain), + .domain(target: .UserDomain, type: .testing), + .core(target: .KeyValueStore, type: .testing) ]) ] ) diff --git a/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift b/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift index 9458197c..47470ffd 100644 --- a/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift +++ b/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift @@ -1,5 +1,6 @@ import Foundation import Localization +import UserDomainInterface extension UserDomainError: LocalizedError { public var errorDescription: String? { diff --git a/Projects/Domain/UserDomain/Tests/LoadCurrentUserRoleUseCaseTests.swift b/Projects/Domain/UserDomain/Tests/LoadCurrentUserRoleUseCaseTests.swift new file mode 100644 index 00000000..396937ea --- /dev/null +++ b/Projects/Domain/UserDomain/Tests/LoadCurrentUserRoleUseCaseTests.swift @@ -0,0 +1,44 @@ +import XCTest +@testable import UserDomainTesting +@testable import UserDomain + +class LoadCurrentUserRoleUseCaseTests: XCTestCase { + var loadCurrentUserRoleUseCase: LoadCurrentUserRoleUseCaseImpl! + var userRepositorySpy: UserRepositorySpy! + + override func setUp() { + super.setUp() + userRepositorySpy = UserRepositorySpy() + loadCurrentUserRoleUseCase = LoadCurrentUserRoleUseCaseImpl(userRepository: userRepositorySpy) + } + + override func tearDown() { + loadCurrentUserRoleUseCase = nil + userRepositorySpy = nil + super.tearDown() + } + + func testCallAsFunction() { + // Given + userRepositorySpy.loadCurrentUserRoleReturn = .member + + // When + do { + let currentUserRole = try loadCurrentUserRoleUseCase() + + // Then + XCTAssertEqual( + userRepositorySpy.loadCurrentUserRoleCallCount, + 1, + "loadCurrentUserRole should be called once" + ) + XCTAssertEqual( + currentUserRole, + .member, + "The returned currentUserRole should be .admin" + ) + } catch { + XCTFail("Unexpected error thrown: \(error)") + } + } +} diff --git a/Projects/Domain/UserDomain/Tests/LocalUserDataSourceTests.swift b/Projects/Domain/UserDomain/Tests/LocalUserDataSourceTests.swift new file mode 100644 index 00000000..0ed186ad --- /dev/null +++ b/Projects/Domain/UserDomain/Tests/LocalUserDataSourceTests.swift @@ -0,0 +1,58 @@ +import UserDomainInterface +import XCTest +@testable import UserDomainTesting +@testable import UserDomain +@testable import KeyValueStoreTesting + +final class LocalUserDataSourceTests: XCTestCase { + var localUserDataSource: LocalUserDataSourceImpl! + var keyValueStoreFake: DictionaryKeyValueStore! + + override func setUp() { + super.setUp() + keyValueStoreFake = DictionaryKeyValueStore() + localUserDataSource = LocalUserDataSourceImpl(keyValueStore: keyValueStoreFake) + } + + override func tearDown() { + localUserDataSource = nil + keyValueStoreFake = nil + super.tearDown() + } + + func testLoadCurrentUserRole_Success() { + // Given + keyValueStoreFake.save(key: .userRole, value: UserRoleType.member.rawValue) + + // When + do { + let currentUserRole = try localUserDataSource.loadCurrentUserRole() + + // Then + XCTAssertEqual( + currentUserRole, + .member, + "The returned currentUserRole should be .admin" + ) + } catch { + XCTFail("Unexpected error thrown: \(error)") + } + } + + func testLoadCurrentUserRole_ThrowsError() { + // When + do { + _ = try localUserDataSource.loadCurrentUserRole() + + // Then + XCTFail("Expected error UserDomainError.cannotFindUserRole not thrown") + } catch { + // Then + XCTAssertEqual( + error as? UserDomainError, + UserDomainError.cannotFindUserRole, + "Unexpected error type" + ) + } + } +} diff --git a/Projects/Domain/UserDomain/Tests/UserDomainTest.swift b/Projects/Domain/UserDomain/Tests/UserDomainTest.swift deleted file mode 100644 index e1c1e167..00000000 --- a/Projects/Domain/UserDomain/Tests/UserDomainTest.swift +++ /dev/null @@ -1,11 +0,0 @@ -import XCTest - -final class UserDomainTests: XCTestCase { - override func setUpWithError() throws {} - - override func tearDownWithError() throws {} - - func testExample() { - XCTAssertEqual(1, 1) - } -} diff --git a/Projects/Domain/UserDomain/Tests/UserRepositoryTest.swift b/Projects/Domain/UserDomain/Tests/UserRepositoryTest.swift new file mode 100644 index 00000000..ce01b5dd --- /dev/null +++ b/Projects/Domain/UserDomain/Tests/UserRepositoryTest.swift @@ -0,0 +1,44 @@ +import XCTest +@testable import UserDomainTesting +@testable import UserDomain + +final class UserRepositoryTests: XCTestCase { + var userRepository: UserRepositoryImpl! + var localUserDataSourceSpy: LocalUserDataSourceSpy! + + override func setUp() { + super.setUp() + localUserDataSourceSpy = LocalUserDataSourceSpy() + userRepository = UserRepositoryImpl(localUserDataSource: localUserDataSourceSpy) + } + + override func tearDown() { + userRepository = nil + localUserDataSourceSpy = nil + super.tearDown() + } + + func testLoadCurrentUserRole() { + // Given + localUserDataSourceSpy.loadCurrentUserRoleReturn = .member + + // When + do { + let currentUserRole = try userRepository.loadCurrentUserRole() + + // Then + XCTAssertEqual( + localUserDataSourceSpy.loadCurrentUserRoleCallCount, + 1, + "loadCurrentUserRole should be called once" + ) + XCTAssertEqual( + currentUserRole, + .member, + "The returned currentUserRole should be .member" + ) + } catch { + XCTFail("Unexpected error thrown: \(error)") + } + } +} diff --git a/Projects/UserInterface/DesignSystem/Sources/CheckBox/DotoriCheckBox.swift b/Projects/UserInterface/DesignSystem/Sources/CheckBox/DotoriCheckBox.swift index f1176276..492d2d8f 100644 --- a/Projects/UserInterface/DesignSystem/Sources/CheckBox/DotoriCheckBox.swift +++ b/Projects/UserInterface/DesignSystem/Sources/CheckBox/DotoriCheckBox.swift @@ -74,14 +74,14 @@ public final class DotoriCheckBox: UIControl { setup() } - //MARK: - handle touches + // MARK: - handle touches public override func touchesEnded(_ touches: Set, with event: UIEvent?) { super.touchesEnded(touches, with: event) sendActions(for: .valueChanged) isChecked.toggle() } - //MARK: - Increase hit area + // MARK: - Increase hit area public override func point( inside point: CGPoint, with event: UIEvent? From 5dafbd47a74a8fa6b3de9cdfc07c251a34faafea Mon Sep 17 00:00:00 2001 From: baegteun Date: Tue, 4 Jul 2023 15:10:08 +0900 Subject: [PATCH 4/5] =?UTF-8?q?:art:=20::=20=EC=9C=A0=EC=A0=80=EC=97=90?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=EB=A9=94=EC=8B=9C=EC=A7=80=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EC=98=81=EC=96=B4=EB=A1=9C=EB=A7=8C=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserDomain/Sources/Error/UserDomainErrorDescription.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift b/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift index 47470ffd..258558f9 100644 --- a/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift +++ b/Projects/Domain/UserDomain/Sources/Error/UserDomainErrorDescription.swift @@ -6,7 +6,7 @@ extension UserDomainError: LocalizedError { public var errorDescription: String? { switch self { case .cannotFindUserRole: - return "유저의 권한을 찾을 수 없습니다. 다시 로그인해주세요." + return "Cannot find user role" } } } From 9ec666524eac5d9f004e95f2a8938348373266b9 Mon Sep 17 00:00:00 2001 From: baegteun Date: Tue, 4 Jul 2023 15:15:49 +0900 Subject: [PATCH 5/5] :sparkles: :: UserDomainAssembly --- .../App/Sources/Application/AppDelegate.swift | 4 +++- .../Sources/Assembly/UserDomainAssembly.swift | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Projects/Domain/UserDomain/Sources/Assembly/UserDomainAssembly.swift diff --git a/Projects/App/Sources/Application/AppDelegate.swift b/Projects/App/Sources/Application/AppDelegate.swift index be5d7cbb..35c8ce70 100644 --- a/Projects/App/Sources/Application/AppDelegate.swift +++ b/Projects/App/Sources/Application/AppDelegate.swift @@ -14,6 +14,7 @@ import SigninFeature import SignupFeature import Swinject import UIKit +import UserDomain @main class AppDelegate: UIResponder, UIApplicationDelegate { @@ -37,7 +38,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { SignupAssembly(), RenewalPasswordAssembly(), RootAssembly(), - AuthDomainAssembly() + AuthDomainAssembly(), + UserDomainAssembly() ], container: AppDelegate.container) IQKeyboardManager.shared.enable = true IQKeyboardManager.shared.enableAutoToolbar = true diff --git a/Projects/Domain/UserDomain/Sources/Assembly/UserDomainAssembly.swift b/Projects/Domain/UserDomain/Sources/Assembly/UserDomainAssembly.swift new file mode 100644 index 00000000..79da9c1d --- /dev/null +++ b/Projects/Domain/UserDomain/Sources/Assembly/UserDomainAssembly.swift @@ -0,0 +1,22 @@ +import KeyValueStoreInterface +import Swinject +import UserDomainInterface + +public final class UserDomainAssembly: Assembly { + public init() {} + public func assemble(container: Container) { + container.register(LocalUserDataSource.self) { resolver in + LocalUserDataSourceImpl(keyValueStore: resolver.resolve(KeyValueStore.self)!) + } + .inObjectScope(.container) + + container.register(UserRepository.self) { resolver in + UserRepositoryImpl(localUserDataSource: resolver.resolve(LocalUserDataSource.self)!) + } + .inObjectScope(.container) + + container.register(LoadCurrentUserRoleUseCase.self) { resolver in + LoadCurrentUserRoleUseCaseImpl(userRepository: resolver.resolve(UserRepository.self)!) + } + } +}