Beispiel #1
0
  @Test
  public void shouldCheckForTheAbsenceOfErrorMessages() {
    assertTrue(errors.hasNoErrors());

    errors.add("An error message");

    assertFalse(errors.hasNoErrors());
  }
Beispiel #2
0
  @Test
  public void shouldReturnTheNumberOfErrorMessages() {
    Errors newErrors = new Errors();
    newErrors.add("Error message 1");
    newErrors.add("Error message 2");
    errors.addAll(newErrors);

    int errorsCount = errors.getCount();
    assertEquals(2, errorsCount);
  }
Beispiel #3
0
  @Test
  public void shouldAddACollectionOfErrorMessages() {
    Errors newErrors = new Errors();
    newErrors.add("Error message 1");
    newErrors.add("Error message 2");
    String expectedErrorMessage = "Error message 1" + "," + "Error message 2";

    errors.addAll(newErrors);

    String actualErrorMessage = errors.allMessages();
    assertEquals(expectedErrorMessage, actualErrorMessage);
  }
Beispiel #4
0
  @Test
  public void shouldGetAllErrors() {
    String errorMessage1 = "An error message";
    String errorMessage2 = "Another error message";
    errors.add(errorMessage1);
    errors.add(errorMessage2);
    String expectedErrorMessage = errorMessage1 + "," + errorMessage2;

    String actualErrorMessage = errors.allMessages();

    assertEquals(expectedErrorMessage, actualErrorMessage);
  }