Skip to content

Commit

Permalink
Refactoring a few tests down to oneline since they're easily understa…
Browse files Browse the repository at this point in the history
…ndable
  • Loading branch information
TonyBrobston committed Aug 3, 2016
1 parent 0ebc5fb commit 4febd70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
22 changes: 8 additions & 14 deletions src/test/java/com/vendingmachine/domain/ProductTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
public class ProductTest {
@DataProvider
public static Object[][] productConverterDataProvider() {
return new Object[][] {
{ "chips", CHIPS },
{ "Candy", CANDY }
return new Object[][]{
{"chips", CHIPS},
{"Candy", CANDY}
};
}

Expand All @@ -30,22 +30,16 @@ public void shouldConvertStringsToBigDecimalInSetter(String in, BigDecimal out)

@DataProvider
public static Object[][] isEnoughCoinDataProvider() {
return new Object[][] {
{ new BigDecimal(0.75), CHIPS, true },
{ new BigDecimal(0.25), CHIPS, false },
{ null, CHIPS, false }
return new Object[][]{
{new BigDecimal(0.75), CHIPS, true},
{new BigDecimal(0.25), CHIPS, false},
{null, CHIPS, false}
};
}

@Test
@UseDataProvider("isEnoughCoinDataProvider")
public void shouldPassIfIsEnoughCoinForProduct(BigDecimal runningTotal, BigDecimal value, boolean expected) {
Product product = new Product().setValue(value);

boolean isEnoughForProduct = product.isEnoughCoin(runningTotal);

assertEquals(expected, isEnoughForProduct);
assertEquals(expected, new Product().setValue(value).isEnoughCoin(runningTotal));
}


}
6 changes: 1 addition & 5 deletions src/test/java/com/vendingmachine/utils/FormatterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
public class FormatterTest {
@Test
public void shouldFormatMoney() {
BigDecimal bigDecimal = new BigDecimal(13.37);

String currency = new Formatter().toCurrency(bigDecimal);

assertEquals("$13.37", currency);
assertEquals("$13.37", new Formatter().toCurrency(new BigDecimal(13.37)));
}
}

0 comments on commit 4febd70

Please sign in to comment.