From f8bf17b1081e5898500ef6822dfbdb7564cc33b7 Mon Sep 17 00:00:00 2001 From: Yves Bonjour Date: Wed, 14 Mar 2018 10:55:39 +0100 Subject: [PATCH] Creates default value for Completable --- .../kotlin/ch/yvu/rxpect/mockito/DefaultValueGenerator.kt | 4 ++++ .../ch/yvu/rxpect/mockito/DefaultValueGeneratorTest.kt | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/kotlin/ch/yvu/rxpect/mockito/DefaultValueGenerator.kt b/src/main/kotlin/ch/yvu/rxpect/mockito/DefaultValueGenerator.kt index fc08866..3bf86ce 100644 --- a/src/main/kotlin/ch/yvu/rxpect/mockito/DefaultValueGenerator.kt +++ b/src/main/kotlin/ch/yvu/rxpect/mockito/DefaultValueGenerator.kt @@ -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 @@ -59,6 +60,9 @@ inline fun defaultValue(): T? = Single::class -> { Single.never() as T } + Completable::class -> { + Completable.complete() as T + } else -> { null } diff --git a/src/test/kotlin/ch/yvu/rxpect/mockito/DefaultValueGeneratorTest.kt b/src/test/kotlin/ch/yvu/rxpect/mockito/DefaultValueGeneratorTest.kt index ce74498..3c465c7 100644 --- a/src/test/kotlin/ch/yvu/rxpect/mockito/DefaultValueGeneratorTest.kt +++ b/src/test/kotlin/ch/yvu/rxpect/mockito/DefaultValueGeneratorTest.kt @@ -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 @@ -123,6 +124,13 @@ class DefaultValueGeneratorTest { assertThat(value, `is`(Single.never())) } + @Test + fun generatesCompletable() { + val value = defaultValue() + + assertThat(value, `is`(Completable.complete())) + } + @Test fun returnsNullForUnknownType() { val value = defaultValue()