@Test
 public void showDialog_shouldShowDialog() throws Exception {
   final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
   activity.showDialog(1);
   Dialog dialog = ShadowDialog.getLatestDialog();
   assertTrue(dialog.isShowing());
 }
 @Test
 public void dismissDialog_shouldDismissPreviouslyShownDialog() throws Exception {
   final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
   activity.showDialog(1);
   activity.dismissDialog(1);
   Dialog dialog = ShadowDialog.getLatestDialog();
   assertFalse(dialog.isShowing());
 }
  @Test
  public void showDialog_shouldReuseDialogs() {
    final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
    activity.showDialog(1);
    Dialog firstDialog = ShadowDialog.getLatestDialog();
    activity.showDialog(1);

    Dialog secondDialog = ShadowDialog.getLatestDialog();
    assertSame("dialogs should be the same instance", firstDialog, secondDialog);
  }
  @Test
  public void removeDialog_shouldCreateDialogAgain() {
    final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
    activity.showDialog(1);
    Dialog firstDialog = ShadowDialog.getLatestDialog();

    activity.removeDialog(1);
    assertNull(shadowOf(activity).getDialogById(1));

    activity.showDialog(1);
    Dialog secondDialog = ShadowDialog.getLatestDialog();

    assertNotSame("dialogs should not be the same instance", firstDialog, secondDialog);
  }
 @Test(expected = IllegalArgumentException.class)
 public void dismissDialog_shouldThrowExceptionIfDialogWasNotPreviouslyShown() throws Exception {
   final DialogCreatingActivity activity = create(DialogCreatingActivity.class);
   activity.dismissDialog(1);
 }