コード例 #1
0
  @Test
  public void testPayNegativeFine() {
    float fines = 5f;
    float payment = -5f;

    member.addFine(fines);

    System.out.println(
        "\nThus test demonstrates a negative payment of a fine. The test is successful if the function "
            + "\ngives out an exception and does not change the fine value.");

    boolean b;
    member.payFine(payment);

    System.out.print(
        "Fines value: "
            + fines
            + ", Payment value: "
            + payment
            + ", Fines value after payment: "
            + member.getFineAmount());

    if (member.getFineAmount() == fines) {
      b = true;

      System.out.println(" -- PASS");
    } else {
      b = false;
      System.out.println(" -- FAIL");
    }

    assertTrue(b);
  }
コード例 #2
0
  @Test
  public void testPayCompleteFine() {
    float fines = 5f;
    float payment = 5f;

    member.addFine(fines);

    System.out.println(
        "\nThus test demonstrates a complete payment of a fine. The test is successful if the fine value after payment is at 0.");

    boolean b;
    member.payFine(payment);

    System.out.print(
        "Fines value: "
            + fines
            + ", Payment value: "
            + payment
            + ", Fines value after payment: "
            + member.getFineAmount());

    if (member.getFineAmount() == 0f) {
      b = true;
      System.out.println(" -- PASS");
    } else {
      b = false;
      System.out.println(" -- FAIL");
    }

    assertTrue(b);
  }
コード例 #3
0
  @Test
  public void testPaySmallFine() {
    float fines = 5f;
    float payment = 2f;

    member.addFine(fines);

    System.out.println(
        "\nThus test demonstrates a partial payment of a fine. The test is successful if the fine value after payment is lower than its "
            + "\nprevious value.");

    boolean b;
    member.payFine(payment);

    System.out.print(
        "Fines value: "
            + fines
            + ", Payment value: "
            + payment
            + ", Fines value after payment: "
            + member.getFineAmount());

    if (member.getFineAmount() < fines) {
      b = true;
      System.out.println(" -- PASS");
    } else {
      b = false;
      System.out.println(" -- FAIL");
    }

    assertTrue(b);
  }
コード例 #4
0
  @Test
  public void testGetFineAmount() {
    float fines = 2f;
    member.addFine(fines);

    EasyMock.expect(memberMock.getFineAmount()).andReturn(member.getFineAmount());
    EasyMock.replay(memberMock);

    System.out.println(
        "\nThis test will return the value of a fine amount. The test is successful if the returned fine amount is equal to the"
            + "\nvariable fine amount");

    boolean b;
    if (fines == memberMock.getFineAmount()) {
      b = true;
      System.out.println(
          "The amount "
              + member.getFineAmount()
              + " match the fine given from variable fines "
              + fines
              + "! -- PASS");
    } else {
      b = false;
      System.out.println(
          "The amount "
              + member.getFineAmount()
              + " does not match the fine given from variable fines "
              + fines
              + "! -- FAIL");
    }
    assertTrue(b);
  }
コード例 #5
0
  @Test
  public void testHasNotReachedFineLimit() {
    float fine = 2f;
    member.addFine(fine);

    EasyMock.expect(memberMock.hasReachedFineLimit()).andReturn(member.hasReachedFineLimit());
    EasyMock.replay(memberMock);

    System.out.println(
        "\nThis test demonstrates a scenario where the member has not reached over the fine limit with the"
            + "\nfines incurred.");

    boolean b = memberMock.hasReachedFineLimit();

    assertFalse(b);

    if (b)
      System.out.println(
          "This member has exceeded the fine limit of "
              + Member.FINE_LIMIT
              + " with "
              + member.getFineAmount()
              + "! -- FAIL");
    else
      System.out.println(
          "This member has not exceeded the fine limit of "
              + Member.FINE_LIMIT
              + " with "
              + member.getFineAmount()
              + "! -- PASS");
  }
コード例 #6
0
  @Test
  public void testAddFine() {
    float fines = 2f;

    float previousFine = member.getFineAmount();
    member.addFine(fines);

    System.out.println(
        "\nThis test will add a fine value into the member class, then the fine value of the member class is compared to its value before"
            + "\nthe fine value is added.");

    assertNotEquals(previousFine, member.getFineAmount());

    System.out.print(
        "Fine added: "
            + fines
            + ", fine value before addFine(): "
            + previousFine
            + ", fine value after addFine(): "
            + member.getFineAmount());
    if (fines == previousFine) System.out.println(" -- FAIL");
    else System.out.println(" -- PASS");
  }