From 2214462a4341ee255fa841a76667e0bec06b6a87 Mon Sep 17 00:00:00 2001 From: Zied Naimi Date: Sun, 3 Mar 2019 23:40:18 +0100 Subject: [PATCH] Add Celtia with tests --- .../res/chill/domain/zoubaidas/Celtia.java | 23 ++++++++++++++ .../chill/domain/zoubaidas/CeltiaTest.java | 31 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/chill/domain/zoubaidas/Celtia.java create mode 100644 src/test/java/ch/heigvd/res/chill/domain/zoubaidas/CeltiaTest.java diff --git a/src/main/java/ch/heigvd/res/chill/domain/zoubaidas/Celtia.java b/src/main/java/ch/heigvd/res/chill/domain/zoubaidas/Celtia.java new file mode 100644 index 000000000..63b307469 --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/zoubaidas/Celtia.java @@ -0,0 +1,23 @@ +package ch.heigvd.res.chill.domain.zoubaidas; + + + +import ch.heigvd.res.chill.domain.IProduct; + +import java.math.BigDecimal; + +public class Celtia implements IProduct { + + public final static String NAME = "Celtia"; + public final static BigDecimal PRICE = new BigDecimal(666); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/chill/domain/zoubaidas/CeltiaTest.java b/src/test/java/ch/heigvd/res/chill/domain/zoubaidas/CeltiaTest.java new file mode 100644 index 000000000..d2cacbb94 --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/zoubaidas/CeltiaTest.java @@ -0,0 +1,31 @@ +package ch.heigvd.res.chill.domain.zoubaidas; + +import ch.heigvd.res.chill.domain.Bartender; +import ch.heigvd.res.chill.protocol.OrderRequest; +import ch.heigvd.res.chill.protocol.OrderResponse; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class CeltiaTest { + + @Test + void thePriceAndNameForCeltiaShouldBeCorrect() { + Celtia beer = new Celtia(); + assertEquals(beer.getName(), Celtia.NAME); + assertEquals(beer.getPrice(), Celtia.PRICE); + } + + @Test + void aBartenderShouldAcceptAnOrderForCeltia() { + Bartender jane = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.zoubaidas.Celtia"; + OrderRequest request = new OrderRequest(5, productName); + OrderResponse response = jane.order(request); + BigDecimal expectedTotalPrice = Celtia.PRICE.multiply(new BigDecimal(5)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } + +} \ No newline at end of file