@Test public void shouldChooseBox(){ when(toeGame.getTurn()).thenReturn(GameSymbol.O); Button button = Mockito.mock(Button.class); when(button.getId()).thenReturn(R.id.box_8); activity.chooseBox(button); ToeStrategy expectedStrategy = new ToeStrategyExplicit(8, GameSymbol.O); verify(toeGame).chooseBox(any(ContentResolver.class), eq(expectedStrategy)); }
public void chooseBox(View view){ String boxIdString = getResources().getResourceEntryName(view.getId()); int boxId = Integer.parseInt(boxIdString.substring(boxIdString.length() - 1)); ToeStrategy strategy = new ToeStrategyExplicit(boxId, toeGame.getTurn()); toeGame.chooseBox(getContentResolver(), strategy); }
GameActivity extends RoboFragmentActivity implements LoaderManager.LoaderCallbacks<Cursor> { public void chooseBox(View view){ String boxIdString = getResources().getResourceEntryName(view.getId()); int boxId = Integer.parseInt(boxIdString.substring(boxIdString.length() - 1)); ToeStrategy strategy = new ToeStrategyExplicit(boxId, toeGame.getTurn()); toeGame.chooseBox(getContentResolver(), strategy); } }
GameActivity extends RoboFragmentActivity implements LoaderManager.LoaderCallbacks<Cursor> { public void chooseBox(View view){ String boxIdString = getResources().getResourceEntryName(view.getId()); int boxId = Integer.parseInt(boxIdString.substring(boxIdString.length() - 1)); ToeStrategy strategy = new ToeStrategyExplicit(boxId, toeGame.getTurn()); toeGame.chooseBox(getContentResolver(), strategy); }  }
GameActivity extends RoboFragmentActivity implements LoaderManager.LoaderCallbacks<Cursor> { public void chooseBox(View view){ String boxIdString = getResources().getResourceEntryName(view.getId()); int boxId = Integer.parseInt(boxIdString.substring(boxIdString.length() - 1)); ToeStrategy strategy = new ToeStrategyExplicit(boxId, toeGame.getTurn()); toeGame.chooseBox(getContentResolver(), strategy); }  void chooseBox(View view); void newGame(View view); @Override Loader<Cursor> onCreateLoader(int id, Bundle args); @Override void onLoadFinished(Loader<Cursor> loader, Cursor data); @Override void onLoaderReset(Loader<Cursor> loader); }
GameActivity extends RoboFragmentActivity implements LoaderManager.LoaderCallbacks<Cursor> { public void chooseBox(View view){ String boxIdString = getResources().getResourceEntryName(view.getId()); int boxId = Integer.parseInt(boxIdString.substring(boxIdString.length() - 1)); ToeStrategy strategy = new ToeStrategyExplicit(boxId, toeGame.getTurn()); toeGame.chooseBox(getContentResolver(), strategy); }  void chooseBox(View view); void newGame(View view); @Override Loader<Cursor> onCreateLoader(int id, Bundle args); @Override void onLoadFinished(Loader<Cursor> loader, Cursor data); @Override void onLoaderReset(Loader<Cursor> loader);  }