@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(Robolectric.shadowOf(activity).getDialogById(1));

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

    assertNotSame("dialogs should not be the same instance", firstDialog, secondDialog);
  }
 @Test
 public void shouldCallOnCreateDialogFromShowDialog() {
   ActivityWithOnCreateDialog activity = create(ActivityWithOnCreateDialog.class);
   activity.showDialog(123);
   assertTrue(activity.onCreateDialogWasCalled);
   assertThat(ShadowDialog.getLatestDialog()).isNotNull();
 }
 @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());
 }