コード例 #1
0
  @Test
  public void testOnCreate() throws Exception {
    final ReceiptPresenter presenter = mock(ReceiptPresenter.class);
    ReceiptFragment fragment =
        new ReceiptFragment() {
          @Override
          public ReceiptPresenter createPresenter() {
            return presenter;
          }
        };
    FragmentController<ReceiptFragment> fragmentController = FragmentController.of(fragment);
    fragmentController.create();
    verify(presenter).create();

    assertEquals(fragment.getString(R.string.empty_receipt), fragment.receiptTextView.getText());
  }
コード例 #2
0
  @Test
  public void testReloadWithEmptyReceipt() throws Exception {
    final ReceiptPresenter presenter = mock(ReceiptPresenter.class);
    ReceiptFragment fragment =
        new ReceiptFragment() {
          @Override
          public ReceiptPresenter createPresenter() {
            return presenter;
          }
        };
    FragmentController<ReceiptFragment> fragmentController = FragmentController.of(fragment);
    fragmentController.create();

    Receipt receipt = new Receipt();
    fragment.reloadData(receipt);
    assertEquals(fragment.getString(R.string.empty_receipt), fragment.receiptTextView.getText());

    receipt.addBasketItem(new BasketItem(new Product("book", 12.0, ProductType.BOOK, false), 1));
    fragment.reloadData(receipt);
    assertEquals(
        "1 book: 12.00\\nSales Taxes: 0.00\\nTotal: 12.00", fragment.receiptTextView.getText());
  }