package net.grandcentrix.thirtyinch.rx2;

import net.grandcentrix.thirtyinch.TiView;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import io.reactivex.observers.TestObserver;

import static org.mockito.Mockito.mock;

public class RxTiPresenterUtilsTest {

    private TiMockPresenter mPresenter;

    private TiView mView;

    @Before
    public void setUp() throws Exception {
        mView = mock(TiView.class);
        mPresenter = new TiMockPresenter();
    }

    @After
    public void tearDown() throws Exception {
        mPresenter = null;
        mView = null;
    }

    @Test
    public void testIsViewReady_AttachView_ShouldCallValueFalseTrue() throws Exception {
        mPresenter.create();

        final TestObserver<Boolean> test = RxTiPresenterUtils.isViewReady(mPresenter).test();

        mPresenter.attachView(mView);
        test.assertValues(false, true);
    }

    @Test
    public void testIsViewReady_BeforeAttachView_ShouldCallValueFalse() throws Exception {
        mPresenter.create();

        final TestObserver<Boolean> test = RxTiPresenterUtils.isViewReady(mPresenter).test();

        test.assertValue(false);
    }

    @Test
    public void testIsViewReady_DisposeBeforeAttachView_ShouldRemoveCallback() throws Exception {
        mPresenter.create();

        final TestObserver<Boolean> test = RxTiPresenterUtils.isViewReady(mPresenter).test();

        test.assertValue(false);
        test.dispose();
        test.isDisposed();
        mPresenter.attachView(mView);
        test.assertValue(false);
    }
}
@@ -35,16 +35,64 @@
 h.rx2;%0A%0A
+import net.grandcentrix.thirtyinch.TiPresenter;%0A
 import n
@@ -126,16 +126,16 @@
 TiView;%0A
-
 %0Aimport 
@@ -339,20 +339,16 @@
 ivate Ti
-Mock
 Presente
@@ -507,20 +507,16 @@
 = new Ti
-Mock
 Presente
@@ -518,16 +518,28 @@
 senter()
+ %7B%0A        %7D
 ;%0A    %7D%0A

Remove TiMockPresenter from tests