use of com.hannesdorfmann.mosby3.mvi.MviBasePresenter in project mosby by sockeqwe.
the class MviBasePresenterTest method bindIntentsAndUnbindIntentsOnlyOnce.
@Test
public void bindIntentsAndUnbindIntentsOnlyOnce() {
final AtomicInteger bindInvocations = new AtomicInteger(0);
final AtomicInteger unbindInvocations = new AtomicInteger(0);
MvpView view = new MvpView() {
};
MviBasePresenter<MvpView, Object> presenter = new MviBasePresenter<MvpView, Object>() {
@Override
protected void bindIntents() {
bindInvocations.incrementAndGet();
}
@Override
protected void unbindIntents() {
super.unbindIntents();
unbindInvocations.incrementAndGet();
}
};
presenter.attachView(view);
presenter.detachView(true);
presenter.attachView(view);
presenter.detachView(true);
presenter.attachView(view);
presenter.detachView(false);
Assert.assertEquals(1, bindInvocations.get());
Assert.assertEquals(1, unbindInvocations.get());
}
use of com.hannesdorfmann.mosby3.mvi.MviBasePresenter in project mosby by sockeqwe.
the class MviBasePresenterTest method resetOnViewDetachedPermanently.
@Test
public void resetOnViewDetachedPermanently() {
final AtomicInteger bindInvocations = new AtomicInteger(0);
final AtomicInteger unbindInvocations = new AtomicInteger(0);
MvpView view = new MvpView() {
};
MviBasePresenter<MvpView, Object> presenter = new MviBasePresenter<MvpView, Object>() {
@Override
protected void bindIntents() {
bindInvocations.incrementAndGet();
}
@Override
protected void unbindIntents() {
super.unbindIntents();
unbindInvocations.incrementAndGet();
}
};
presenter.attachView(view);
presenter.detachView(false);
presenter.attachView(view);
presenter.detachView(true);
presenter.attachView(view);
presenter.detachView(false);
Assert.assertEquals(2, bindInvocations.get());
Assert.assertEquals(2, unbindInvocations.get());
}
Aggregations