@Test public void testAdditionSuccess() throws Exception { when(calculator.calculate("1", "1", Sign.PLUS)).thenReturn(Observable.just(2.0f)); presenter.makeCalculation("1", "1", Sign.PLUS); verify(view).showResult(2.0f); }
@Override public void makeCalculation(String firstNumber, String secondNumber, String selectedSign) { subscription = calculator.calculate(firstNumber, secondNumber, selectedSign) .subscribe(view::showResult, throwable -> view.showError()); }
MainPresenterImpl implements MainPresenter { @Override public void makeCalculation(String firstNumber, String secondNumber, String selectedSign) { subscription = calculator.calculate(firstNumber, secondNumber, selectedSign) .subscribe(view::showResult, throwable -> view.showError()); } }
MainPresenterImpl implements MainPresenter { @Override public void makeCalculation(String firstNumber, String secondNumber, String selectedSign) { subscription = calculator.calculate(firstNumber, secondNumber, selectedSign) .subscribe(view::showResult, throwable -> view.showError()); } MainPresenterImpl(Calculator calculator, MainView view); }
MainPresenterImpl implements MainPresenter { @Override public void makeCalculation(String firstNumber, String secondNumber, String selectedSign) { subscription = calculator.calculate(firstNumber, secondNumber, selectedSign) .subscribe(view::showResult, throwable -> view.showError()); } MainPresenterImpl(Calculator calculator, MainView view); @Override void init(); @Override void makeCalculation(String firstNumber, String secondNumber, String selectedSign); @Override void destroy(); }
MainPresenterImpl implements MainPresenter { @Override public void makeCalculation(String firstNumber, String secondNumber, String selectedSign) { subscription = calculator.calculate(firstNumber, secondNumber, selectedSign) .subscribe(view::showResult, throwable -> view.showError()); } MainPresenterImpl(Calculator calculator, MainView view); @Override void init(); @Override void makeCalculation(String firstNumber, String secondNumber, String selectedSign); @Override void destroy(); final Calculator calculator; public Subscription subscription; }