package se.ericthelin.fractions;

import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class InvalidFractionFormatExceptionTest {

	@Test(expected = NullPointerException.class)
	public void rejectsNullText() {
		new InvalidFractionFormatException(null);
	}

	@Test
	public void hasInformativeMessage() {
		// Given
		String text = "foo";

		// When
		InvalidFractionFormatException e = new InvalidFractionFormatException(text);

		// Then
		assertThat(
				e.getMessage(),
				is("Expected either a fraction or a whole number, but got \"foo\". " +
						"Valid examples: \"1/2\", \"3\", \"-4/5\", \"-6\", \"78/9\"."));
	}
}
@@ -317,16 +317,137 @@
 l);%0A%09%7D%0A%0A
+%09@Test%0A%09public void remembersText() %7B%0A%09%09assertThat(new InvalidFractionFormatException(%22foo%22).getText(), is(%22foo%22));%0A%09%7D%0A%09%0A
 %09@Test%0A%09

Check that InvalidFractionFormatException remembers text