Skip to content

Commit

Permalink
Creates default value for Completable
Browse files Browse the repository at this point in the history
  • Loading branch information
Yves Bonjour committed Mar 14, 2018
1 parent 06abd49 commit f8bf17b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.yvu.rxpect.mockito

import io.reactivex.Completable
import io.reactivex.Maybe
import io.reactivex.Observable
import io.reactivex.Single
Expand Down Expand Up @@ -59,6 +60,9 @@ inline fun <reified T> defaultValue(): T? =
Single::class -> {
Single.never<Any>() as T
}
Completable::class -> {
Completable.complete() as T
}
else -> {
null
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ch.yvu.rxpect.mockito

import io.reactivex.Completable
import io.reactivex.Maybe
import io.reactivex.Observable
import io.reactivex.Single
Expand Down Expand Up @@ -123,6 +124,13 @@ class DefaultValueGeneratorTest {
assertThat(value, `is`(Single.never<Int>()))
}

@Test
fun generatesCompletable() {
val value = defaultValue<Completable>()

assertThat(value, `is`(Completable.complete()))
}

@Test
fun returnsNullForUnknownType() {
val value = defaultValue<Runnable>()
Expand Down

0 comments on commit f8bf17b

Please sign in to comment.