Last active
December 23, 2022 19:47
-
-
Save trikitrok/a9b2b77762045a77cfd9c6854046add7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package unit_tests; | |
import beverages.*; | |
import org.junit.Test; | |
import static org.hamcrest.CoreMatchers.is; | |
import static org.hamcrest.MatcherAssert.assertThat; | |
import static org.hamcrest.Matchers.closeTo; | |
public class BeveragesPricingTest { | |
private static final double PRECISION = 0.001; | |
@Test | |
public void computes_coffee_price() { | |
Beverage coffee = new Coffee(); | |
assertThat(coffee.price(), is(closeTo(1.20, PRECISION))); | |
} | |
@Test | |
public void computes_tea_price() { | |
Beverage tea = new Tea(); | |
assertThat(tea.price(), is(closeTo(1.50, PRECISION))); | |
} | |
@Test | |
public void computes_hot_chocolate_price() { | |
Beverage hotChocolate = new HotChocolate(); | |
assertThat(hotChocolate.price(), is(closeTo(1.45, PRECISION))); | |
} | |
@Test | |
public void computes_tea_with_milk_price() { | |
Tea teaWithMilk = new TeaWithMilk(); | |
assertThat(teaWithMilk.price(), is(closeTo(1.60, PRECISION))); | |
} | |
@Test | |
public void computes_coffee_with_milk_price() { | |
Coffee coffeeWithMilk = new CoffeeWithMilk(); | |
assertThat(coffeeWithMilk.price(), is(closeTo(1.30, PRECISION))); | |
} | |
@Test | |
public void computes_coffee_with_milk_and_cream_price() { | |
Coffee coffeeWithMilkAndCream = new CoffeeWithMilkAndCream(); | |
assertThat(coffeeWithMilkAndCream.price(), is(closeTo(1.45, PRECISION))); | |
} | |
@Test | |
public void computes_hot_chocolate_with_cream_price() { | |
HotChocolateWithCream hotChocolateWithCream = new HotChocolateWithCream(); | |
assertThat(hotChocolateWithCream.price(), is(closeTo(1.60, PRECISION))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment