-
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
ef9abae
commit cabc59b
Showing
8 changed files
with
87 additions
and
9 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
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
34 changes: 34 additions & 0 deletions
34
buffup/src/test/java/com/emmanuelkehinde/buffup/BuffApiServiceTest.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,34 @@ | ||
package com.emmanuelkehinde.buffup | ||
|
||
import com.emmanuelkehinde.buffup.remote.BuffApiService | ||
import com.emmanuelkehinde.buffup.remote.BuffResult | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.coroutines.withContext | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
/** | ||
* Created by Emmanuel Kehinde on 2020-03-31. | ||
*/ | ||
@RunWith(JUnit4::class) | ||
class BuffApiServiceTest { | ||
|
||
@Test | ||
fun `fetchBuff returns Success response`() = runBlocking { | ||
val result = withContext(Dispatchers.Default) { | ||
BuffApiService.getBuff("1") | ||
} | ||
assert(result is BuffResult.Success) | ||
} | ||
|
||
@Test | ||
fun `ensure buffId param falls between 1 to 5`() = runBlocking { | ||
val result = withContext(Dispatchers.Default) { | ||
BuffApiService.getBuff("6") | ||
} | ||
assert(result is BuffResult.Error) | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
buffup/src/test/java/com/emmanuelkehinde/buffup/BuffViewTest.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,35 @@ | ||
package com.emmanuelkehinde.buffup | ||
|
||
import android.app.Activity | ||
import com.emmanuelkehinde.buffup.exceptions.MissingInitializationException | ||
import com.emmanuelkehinde.buffup.view.BuffView | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.Mock | ||
import org.mockito.junit.MockitoJUnitRunner | ||
|
||
/** | ||
* Created by Emmanuel Kehinde on 2020-03-31. | ||
*/ | ||
|
||
@RunWith(MockitoJUnitRunner::class) | ||
class BuffViewTest { | ||
|
||
@Mock | ||
lateinit var activity: Activity | ||
|
||
@Mock | ||
lateinit var buffView: BuffView | ||
|
||
@Test | ||
fun buffViewThrowsInitializationExceptionWhenStartIsCalled() { | ||
try { | ||
buffView.start(activity) | ||
} catch (e: MissingInitializationException) { | ||
|
||
} catch (e: NullPointerException) { | ||
|
||
} | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
buffup/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
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 @@ | ||
mock-maker-inline |