Created
April 4, 2018 15:55
-
-
Save v3n3/167b0ecd9733001c4ce7b027ca43f933 to your computer and use it in GitHub Desktop.
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
val testPublisher = PublishSubject.create<String>() | |
var value:String = "initial" | |
fun myRxFunction(ioThread:Scheduler,mainThread:Scheduler){ | |
testPublisher | |
.subscribeOn(ioThread) | |
.observeOn(mainThread) | |
.subscribe{ | |
saveString(it) | |
} | |
} | |
fun saveString(message:String){ | |
value = message | |
} | |
@Test | |
fun myRxFunctionTest(){ | |
val testString = "test" | |
val testScheduler = TestScheduler() | |
myRxFunction(testScheduler,testScheduler) | |
testScheduler.triggerActions() | |
testPublisher.onNext(testString) | |
assertEquals(value,testString) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment