@Test public void shouldThrowExceptionWhenSeveralNegativeValuesAreInput() throws InvalidValueException { String expectedErrorMessage = "negatives not allowed [-1] [-3] "; String actualErrorMessage = ""; try { accumulator.add("//.\n-1.2.-3"); } catch (InvalidValueException exception) { actualErrorMessage = exception.getMessage(); } assertTrue(actualErrorMessage.startsWith(expectedErrorMessage)); }
@Test public void shouldReturnErrorWhenDelimiterOfCustomLengthHasNoDigitsInbeween() throws InvalidValueException { String expectedErrorMessage = "Invalid entries not allowed [3&&$]"; String actualErrorMessage = ""; try { accumulator.add("//&&|$\n3&&$"); } catch (InvalidValueException exception) { actualErrorMessage = exception.getMessage(); } assertTrue(actualErrorMessage.contains(expectedErrorMessage)); }
@Test public void shouldThrowExceptionWhenThereAreNoNumbersBetweenCustomDelimiters() throws InvalidValueException { String expectedErrorMessage = " is not a valid number"; String actualErrorMessage = ""; try { accumulator.add("//%%|^\n1%%^3"); } catch (InvalidValueException exception) { actualErrorMessage = exception.getMessage(); } assertThat(actualErrorMessage, is(expectedErrorMessage)); }
@Test public void shouldThrowExceptionWhenSeveralNegativeValuesAreInputUsingMulipleDelimitersOfMultipleLength() throws InvalidValueException { String expectedErrorMessage = "negatives not allowed [-9] [-3] "; String actualErrorMessage = ""; try { accumulator.add("//%%|^\n1%%-9^-3"); } catch (InvalidValueException exception) { actualErrorMessage = exception.getMessage(); } assertTrue(actualErrorMessage.startsWith(expectedErrorMessage)); }