Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[둘리] 2, 3단계 자동 DI 미션 제출합니다 #28

Merged
merged 57 commits into from
Sep 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
168589f
docs: 요구사항 업데이트
hyemdooly Sep 6, 2023
87d3c2a
docs: 요구사항 업데이트
hyemdooly Sep 7, 2023
657518e
feat: 요구사항에 맞게 CartRepository 변경
hyemdooly Sep 7, 2023
1bdceaf
feat: CartProduct 생성
hyemdooly Sep 7, 2023
5e94a5e
rename: Repository 네이밍 변경
hyemdooly Sep 7, 2023
7ab7e4e
feat: Room 사용 구현
hyemdooly Sep 7, 2023
04ac319
refactor: Inject 로직 분리
hyemdooly Sep 7, 2023
c75db5c
refactor: Inject 로직 분리
hyemdooly Sep 7, 2023
f483bbb
refactor: viewModelFactory 수정
hyemdooly Sep 8, 2023
d2744a7
feat: Field 주입에 사용할 Annotation 추가
hyemdooly Sep 8, 2023
c6393e6
refactor: getInstance Nullable 허용
hyemdooly Sep 8, 2023
8b64b40
refactor: Field 주입으로 변경
hyemdooly Sep 8, 2023
ffa5c7b
feat: Recursive DI 구현
hyemdooly Sep 8, 2023
2254b53
feat: Recursive DI, Field Injection 적용
hyemdooly Sep 8, 2023
8d57300
docs: 요구사항 적용 여부 업데이트
hyemdooly Sep 8, 2023
e2b9366
test: Injector Test 작성
hyemdooly Sep 8, 2023
62465b1
feat: 상품의 position과 CartRepository::deleteCartProduct의 id가 동일한 값임을 보장…
hyemdooly Sep 8, 2023
559b93f
feat: 구분을 위한 추가 Annotation 생성
hyemdooly Sep 8, 2023
f6c41a8
feat: ViewModel 프로퍼티에 annotations 지정
hyemdooly Sep 8, 2023
c0ee682
refactor: 필요없는 괄호 삭제
hyemdooly Sep 8, 2023
38725ee
feat: injector annotation 고려
hyemdooly Sep 8, 2023
55308d0
feat: InMemory, Database 레포지토리 구현
hyemdooly Sep 8, 2023
a80f744
feat: 바뀐 요구사항에 맞게 주입 수정
hyemdooly Sep 8, 2023
15b4fe6
feat: annotation 고려를 위한 instances 수정
hyemdooly Sep 8, 2023
37d31ed
test: 바뀐 코드에 맞게 test 수정
hyemdooly Sep 8, 2023
7f5c22d
docs: 요구사항 충족 여부 수정
hyemdooly Sep 8, 2023
368e9c9
rename: DI 모듈화
hyemdooly Sep 8, 2023
83f960e
docs: 모듈화 충족 여부 수정
hyemdooly Sep 8, 2023
6f0dcf2
test: ViewModel 주입 테스트 수정
hyemdooly Sep 8, 2023
d66108d
test: di module에 InjectorTest 구현
hyemdooly Sep 8, 2023
5abddb2
test: 액티비티 뷰모델 주입 테스트 보완
hyemdooly Sep 8, 2023
b9ebfdf
feat: DI 배포
hyemdooly Sep 8, 2023
0b4f3a1
feat: DI 배포
hyemdooly Sep 8, 2023
2498638
refactor: constructor 제거
hyemdooly Sep 10, 2023
9eecad2
deploy: DI 배포 수정
hyemdooly Sep 11, 2023
8a46ecd
deploy: DI 배포 수정
hyemdooly Sep 11, 2023
8fca93c
refactor: di 버전 수정
hyemdooly Sep 11, 2023
a636e8c
refactor: Qualifier 수정, DI 수정
hyemdooly Sep 13, 2023
7184501
refactor: println() 삭제
hyemdooly Sep 13, 2023
7443924
deploy: publishing 옵션 변경
hyemdooly Sep 13, 2023
353d48b
refactor: implementation 추가
hyemdooly Sep 13, 2023
bbb76a5
deploy: di release
hyemdooly Sep 13, 2023
a89cc44
deploy: di release
hyemdooly Sep 13, 2023
acaa5ef
test: 바뀐 di에 따른 테스트 변경
hyemdooly Sep 13, 2023
e6ee91f
refactor: 배포된 di 적용
hyemdooly Sep 13, 2023
1f27660
refactor: 전단계의 잔해 삭제
hyemdooly Sep 14, 2023
d53b175
refactor: instance return 수정
hyemdooly Sep 14, 2023
885ab4d
refactor: 파라미터명 명시
hyemdooly Sep 14, 2023
fa81116
refactor: 변수명 변경
hyemdooly Sep 14, 2023
77bc755
refactor: 파라미터명 변경
hyemdooly Sep 14, 2023
ad360bb
refactor: 중복 코드 제거
hyemdooly Sep 14, 2023
55bc13c
refactor: T 타입 non null로 변경
hyemdooly Sep 14, 2023
cc6cc2e
refactor: scope function 적용
hyemdooly Sep 14, 2023
6c59beb
refactor: id 계산법 수정
hyemdooly Sep 14, 2023
a7baa40
refactor: assertAll 적용
hyemdooly Sep 14, 2023
47600c6
refactor: kotlin class type 고려 제외
hyemdooly Sep 14, 2023
a91d38b
refactor: Module 개념 추가
hyemdooly Sep 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: kotlin class type 고려 제외
  • Loading branch information
hyemdooly committed Sep 14, 2023
commit 47600c6fe3967ca8c32b4f5e252f31076071faed
25 changes: 6 additions & 19 deletions di/src/test/kotlin/io/hyemdooly/di/InjectorTest.kt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object 주입이나 인자가 여러개인 경우 등 다른 경우의 수를 추가해서 테스트 해봤는데 잘 작동하는 것 확인했습니다!

Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@ class InjectorTest {

class FakeDatabase

interface FakeRepository {
@Inject
val name: String
interface FakeName

@Inject
val items: List<String>
interface FakeRepository {
var name: FakeName
}

// @InMemory
class DefaultFakeRepository(private val database: FakeDatabase) : FakeRepository {
@Inject
override val name: String = ""

@Inject
override val items: List<String> = emptyList()
override lateinit var name: FakeName
}

class FakeViewModel(
Expand All @@ -42,12 +36,10 @@ class InjectorTest {
@Test
fun `Container에서 타입에 맞는 instance를 찾아 의존성을 주입한다`() {
// given
val name = "FakeRepository"
val items = listOf("item1", "item2", "item3")
val name = object : FakeName {}

// when
Container.addInstance(name)
Container.addInstance(items)
Container.addInstance(Injector.inject(FakeDatabase::class))
Container.addInstance(Injector.inject(DefaultFakeRepository::class))
val viewModel = Injector.inject<FakeViewModel>(FakeViewModel::class)
Expand All @@ -57,28 +49,23 @@ class InjectorTest {
{ assertNotNull(viewModel) },
{ assertNotNull(viewModel.fakeRepository) },
{ assertEquals(name, viewModel.fakeRepository.name) },
{ assertEquals(items, viewModel.fakeRepository.items) },
)
}

@Test
fun `Container에서 찾을 수 없는 instance는 재귀로 생성하여 주입한다`() {
// given
val name = "FakeRepository"
val items = listOf("item1", "item2", "item3")
val name = object : FakeName {}

// when
Container.addInstance(name)
Container.addInstance(items)
Container.addInstance(Injector.inject(DefaultFakeRepository::class))
val viewModel = Injector.inject<FakeViewModel>(FakeViewModel::class)

// then
assertAll(
{ assertNotNull(viewModel) },
{ assertNotNull(viewModel.fakeRepository) },
{ assertEquals(name, viewModel.fakeRepository.name) },
{ assertEquals(items, viewModel.fakeRepository.items) },
)
}

Expand Down