Skip to content

Commit

Permalink
#23 PhotoLocationDaoTest.kt 작성 중
Browse files Browse the repository at this point in the history
  • Loading branch information
kimny927 committed Jan 27, 2025
1 parent b7e90df commit 8269e78
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
4 changes: 2 additions & 2 deletions data/src/androidTest/java/ny/photomap/data/MockEntity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ val ENTITY_LIST: List<PhotoLocationEntity>
PhotoLocationEntity(
uri = "$URI_WITH_NUMBER $it",
name = "$it",
latitude = LOCATION_2.first + (it * 1),
longitude = LOCATION_2.second + (it * 1),
latitude = LOCATION_2.first + it,
longitude = LOCATION_2.second + it,
generatedTime = TIME_1 + (it * 10_000),
addedTime = TIME_1 + (it * 20_000),
)
Expand Down
60 changes: 44 additions & 16 deletions data/src/androidTest/java/ny/photomap/data/PhotoLocationDaoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import com.google.common.truth.Truth.assertThat
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import junit.framework.TestCase.assertEquals
import kotlinx.coroutines.test.runTest
import ny.photomap.data.db.PhotoLocationDao
import ny.photomap.data.db.PhotoLocationDatabase
Expand Down Expand Up @@ -38,31 +39,56 @@ class PhotoLocationDaoTest {
}

@Test
fun `모두_조회`() = runTest {
dao.deleteAll()
fun `단일_삽입_후_모든_위치사진_조회`() = runTest {
dao.insert(ENTITY_1)
val list = dao.getAll()
assert(list[0] == ENTITY_1)

assertEquals(ENTITY_1, list[0])
assertEquals(ENTITY_1.uri, list[0].uri)
assertEquals(ENTITY_1.latitude, list[0].latitude)
assertEquals(ENTITY_1.longitude, list[0].longitude)
}

@Test
fun `장소_필터링_조회`() = runTest {
dao.deleteAll()
fun `리스트_삽입_후_모든_위치사진_조회`() = runTest {
dao.insertAll(ENTITY_LIST)
val list = dao.getAll()
assertEquals(list.size, ENTITY_LIST.size)
}


@Test
fun `중심_위치정보에서_반경_범위로_위치사진_조회`() = runTest {
dao.insertAll(ENTITY_LIST)

val list = dao.getLocationOf(
latitude = LOCATION_2.first, longitude = LOCATION_2.second, range = 3.0
)
assertThat(list).hasSize(4)

val list2 = dao.getLocationOf(
latitude = LOCATION_3.first, longitude = LOCATION_3.second, range = 0.0
)

assertThat(list).hasSize(4)
assertThat(list2).hasSize(0)
}

@Test
fun `화면_위아래_옆_범위로_위치사진_조회`() = runTest {

}

@Test
fun `중심_위치정보에서_반경_범위와_기록_날짜_범위로_위치사진_조회`() = runTest {

}

@Test
fun `화면_위아래_옆_범위와_기록_날짜_범위로_위치사진_조회`() = runTest {

}

@Test
fun `장소_시간_필터링_조회`() = runTest {
dao.deleteAll()
dao.insertAll(ENTITY_LIST)

// range 범위 확인
Expand Down Expand Up @@ -98,7 +124,6 @@ class PhotoLocationDaoTest {

@Test
fun `장소_시간_필터링_개수`() = runTest {
dao.deleteAll()
dao.insertAll(ENTITY_LIST)

// range 범위 확인
Expand Down Expand Up @@ -132,13 +157,6 @@ class PhotoLocationDaoTest {
assert(count3 == 1)
}

@Test
fun `추가_단일`() = runTest {
dao.deleteAll()
dao.insert(ENTITY_1)
assertThat(dao.getAll()).hasSize(1)
}

@Test
fun `추가_리스트`() = runTest {
dao.deleteAll()
Expand All @@ -156,5 +174,15 @@ class PhotoLocationDaoTest {
assertThat(dao.getAll()).isEmpty()
}

@Test
fun `기존_정보_제거_후_업데이트`() = runTest {

}

@Test
fun `가장_최근_위치사진_조회`() = runTest {

}


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ny.photomap.data

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.android.qualifiers.ApplicationContext
Expand All @@ -17,5 +18,8 @@ import ny.photomap.data.di.ProvideSingletonModule
class TestDatabaseModule {
@Provides
fun providePhotoLocationDatabase(@ApplicationContext context: Context): PhotoLocationDatabase =
PhotoLocationDatabase.getInstance(context)
Room.inMemoryDatabaseBuilder(
context,
PhotoLocationDatabase::class.java,
).build()
}

0 comments on commit 8269e78

Please sign in to comment.