-
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.
- Loading branch information
1 parent
e95c279
commit 0fb18a7
Showing
10 changed files
with
66 additions
and
14 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
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
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
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
54 changes: 54 additions & 0 deletions
54
app/src/test/java/com/emmanuelkehinde/buffdemo/StreamPlayerViewModelTest.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,54 @@ | ||
package com.emmanuelkehinde.buffdemo | ||
|
||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule | ||
import androidx.lifecycle.Observer | ||
import com.emmanuelkehinde.buffdemo.helpers.VIDEO_URL | ||
import com.emmanuelkehinde.buffdemo.ui.stream_player.StreamPlayerViewModel | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.Mock | ||
import org.mockito.Mockito.verify | ||
import org.mockito.junit.MockitoJUnitRunner | ||
|
||
|
||
/** | ||
* Created by Emmanuel Kehinde on 2020-03-31. | ||
*/ | ||
@RunWith(MockitoJUnitRunner::class) | ||
class StreamPlayerViewModelTest { | ||
|
||
@Rule | ||
@JvmField | ||
val instantTaskExecutorRule = InstantTaskExecutorRule() | ||
|
||
@Mock | ||
lateinit var observer: Observer<String> | ||
|
||
private lateinit var streamPlayerViewModel: StreamPlayerViewModel | ||
|
||
@Before | ||
fun setUp() { | ||
streamPlayerViewModel = StreamPlayerViewModel() // | ||
} | ||
|
||
@Test | ||
fun `videoUrl has an observer`() { | ||
streamPlayerViewModel.videoUrl.observeForever(observer) | ||
assert(streamPlayerViewModel.videoUrl.hasObservers()) | ||
} | ||
|
||
@Test | ||
fun `fetchVideoUrl sets correct value for videoUrl`() { | ||
streamPlayerViewModel.fetchVideoUrl() | ||
assert(streamPlayerViewModel.videoUrl.value == VIDEO_URL) | ||
} | ||
|
||
@Test | ||
fun `fetchVideoUrl should trigger the observer for videoUrl`() { | ||
streamPlayerViewModel.videoUrl.observeForever(observer) | ||
streamPlayerViewModel.fetchVideoUrl() | ||
verify(observer).onChanged(VIDEO_URL) | ||
} | ||
} |
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
Binary file not shown.
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
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
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 |
---|---|---|
|
@@ -21,7 +21,6 @@ allprojects { | |
repositories { | ||
google() | ||
jcenter() | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
|
||
|