@Test public void shouldPrintMonetaryAmount() throws IOException { StringBuilder sb = new StringBuilder(); MonetaryAmount money = Money.of(10, currency); monetaryAmountFormat.print(sb, money); assertEquals(sb.toString(), "R$ 10,00"); }
@Test public void shouldParseMonetaryAmount() throws IOException { MonetaryAmount money = Money.of(10, currency); String parse = monetaryAmountFormat.queryFrom(money); assertEquals(monetaryAmountFormat.parse(parse), money); }
@Test(expectedExceptions = MonetaryParseException.class) public void shouldReturnErrorParseWhenMonetaryAmountIsInvalid() { monetaryAmountFormat.parse("ERROR"); }
@Test(expectedExceptions = NullPointerException.class) public void shouldReturnErrorParseWhenMonetaryAmountIsNull() { monetaryAmountFormat.parse(null); }
@Test public void shouldQueryFromMonetaryAmount() throws IOException { MonetaryAmount money = Money.of(10, currency); assertEquals(monetaryAmountFormat.queryFrom(money), "R$ 10,00"); }
@Test public void shouldQueryFromNullWhenMonetaryAmountIsNull() throws IOException { assertEquals(monetaryAmountFormat.queryFrom(null), "null"); }
@Test public void shouldPrintNullWhenMonetaryAmountIsNull() throws IOException { StringBuilder sb = new StringBuilder(); monetaryAmountFormat.print(sb, null); assertEquals(sb.toString(), "null"); }
@Test(expectedExceptions = NullPointerException.class) public void shouldReturnsErrorWhenAppendableIsNull() throws IOException { monetaryAmountFormat.print(null, null); }
@Test public void shouldReturnContext() { AmountFormatContext context = monetaryAmountFormat.getContext(); Assert.assertEquals(DefaultMonetaryAmountFormatSymbols.STYLE, context.getFormatName()); }