35 lines
1.2 KiB
Java
35 lines
1.2 KiB
Java
package org.mercury_im.messenger;
|
|
|
|
import org.junit.Test;
|
|
import org.mercury_im.messenger.xmpp.MercuryConnection;
|
|
import org.mercury_im.messenger.xmpp.MercuryConnection.ConnectionState;
|
|
|
|
import io.reactivex.observers.TestObserver;
|
|
import io.reactivex.schedulers.TestScheduler;
|
|
import io.reactivex.subjects.BehaviorSubject;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
/**
|
|
* Example local unit test, which will execute on the development machine (host).
|
|
*
|
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
|
*/
|
|
public class ExampleUnitTest {
|
|
@Test
|
|
public void addition_isCorrect() {
|
|
assertEquals(4, 2 + 2);
|
|
}
|
|
|
|
|
|
@Test
|
|
public void test() {
|
|
TestScheduler testScheduler = new TestScheduler();
|
|
BehaviorSubject<ConnectionState> state = BehaviorSubject.createDefault(ConnectionState.closed);
|
|
TestObserver<ConnectionState> observable = state.test();
|
|
assertEquals(ConnectionState.closed, state.getValue());
|
|
state.onNext(ConnectionState.connected);
|
|
assertEquals(ConnectionState.connected, state.getValue());
|
|
observable.assertValues(ConnectionState.connected, ConnectionState.closed).dispose();
|
|
}
|
|
} |