-
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 #88 from azrael8576/feat/data-test-module
Add :core:data-test module for replacing fake objects during Testing
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,14 @@ | ||
plugins { | ||
alias(libs.plugins.pq.android.library) | ||
alias(libs.plugins.pq.android.hilt) | ||
} | ||
|
||
android { | ||
namespace = "com.wei.picquest.core.data.test" | ||
} | ||
|
||
dependencies { | ||
api(projects.core.data) | ||
|
||
implementation(libs.hilt.android.testing) | ||
} |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
12 changes: 12 additions & 0 deletions
12
core/data-test/src/main/java/com/wei/picquest/core/data/test/AlwaysOnlineNetworkMonitor.kt
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,12 @@ | ||
package com.wei.picquest.core.data.test | ||
|
||
import com.wei.picquest.core.data.utils.NetworkMonitor | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flowOf | ||
import javax.inject.Inject | ||
|
||
class AlwaysOnlineNetworkMonitor | ||
@Inject | ||
constructor() : NetworkMonitor { | ||
override val isOnline: Flow<Boolean> = flowOf(true) | ||
} |
33 changes: 33 additions & 0 deletions
33
core/data-test/src/main/java/com/wei/picquest/core/data/test/TestDataModule.kt
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,33 @@ | ||
package com.wei.picquest.core.data.test | ||
|
||
import com.wei.picquest.core.data.di.DataModule | ||
import com.wei.picquest.core.data.repository.DefaultSearchImagesRepository | ||
import com.wei.picquest.core.data.repository.DefaultSearchVideosRepository | ||
import com.wei.picquest.core.data.repository.DefaultUserDataRepository | ||
import com.wei.picquest.core.data.repository.SearchImagesRepository | ||
import com.wei.picquest.core.data.repository.SearchVideosRepository | ||
import com.wei.picquest.core.data.repository.UserDataRepository | ||
import com.wei.picquest.core.data.utils.NetworkMonitor | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.components.SingletonComponent | ||
import dagger.hilt.testing.TestInstallIn | ||
|
||
@Module | ||
@TestInstallIn( | ||
components = [SingletonComponent::class], | ||
replaces = [DataModule::class], | ||
) | ||
interface TestDataModule { | ||
@Binds | ||
fun bindsSearchImagesRepository(searchImagesRepository: DefaultSearchImagesRepository): SearchImagesRepository | ||
|
||
@Binds | ||
fun bindsSearchVideosRepository(searchVideosRepository: DefaultSearchVideosRepository): SearchVideosRepository | ||
|
||
@Binds | ||
fun bindsNetworkMonitor(networkMonitor: AlwaysOnlineNetworkMonitor): NetworkMonitor | ||
|
||
@Binds | ||
fun bindsUserDataRepository(userDataRepository: DefaultUserDataRepository): UserDataRepository | ||
} |
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