From 49f738655224e27ccdcc9eaf1ab8c0f6f9d6112b Mon Sep 17 00:00:00 2001 From: Thierry OTTO Date: Sun, 3 Mar 2019 15:21:33 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20bi=C3=A8re=20CaptaineMousse?= =?UTF-8?q?=20avec=20les=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/thierryotto/CaptaineMousse.java | 21 +++++++++++++ .../thierryotto/CaptaineMousseTest.java | 30 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousse.java create mode 100644 src/test/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousseTest.java diff --git a/src/main/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousse.java b/src/main/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousse.java new file mode 100644 index 0000000..844a8ad --- /dev/null +++ b/src/main/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousse.java @@ -0,0 +1,21 @@ +package ch.heigvd.res.chill.domain.thierryotto; + +import ch.heigvd.res.chill.domain.IProduct; + +import java.math.BigDecimal; + +public class CaptaineMousse implements IProduct { + + public final static String NAME = "Cap'Taine Mousse"; + public final static BigDecimal PRICE = new BigDecimal(3.5); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousseTest.java b/src/test/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousseTest.java new file mode 100644 index 0000000..6d96ca9 --- /dev/null +++ b/src/test/java/ch/heigvd/res/chill/domain/thierryotto/CaptaineMousseTest.java @@ -0,0 +1,30 @@ +package ch.heigvd.res.chill.domain.thierryotto; + +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.*; + +class CaptaineMousseTest { + + @Test + void getName() { + CaptaineMousse beer = new CaptaineMousse(); + assertEquals(beer.getName(), CaptaineMousse.NAME); + assertEquals(beer.getPrice(), CaptaineMousse.PRICE); + } + + @Test + void getPrice() { + Bartender bob = new Bartender(); + String productName = "ch.heigvd.res.chill.domain.thierryotto.CaptaineMousse"; + OrderRequest request = new OrderRequest(3, productName); + OrderResponse response = bob.order(request); + BigDecimal expectedTotalPrice = CaptaineMousse.PRICE.multiply(new BigDecimal(3)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } +} \ No newline at end of file