From 203f11c927d9a1c979a2da99bbf2e73122191273 Mon Sep 17 00:00:00 2001 From: voknelim Date: Tue, 12 Mar 2019 18:47:51 +0100 Subject: [PATCH] ma pizza a ton gout --- .../res/pizza/domain/voknelim/ATonGout.java | 21 ++++++++++++ .../pizza/domain/voknelim/ATonGoutTest.java | 32 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/pizza/domain/voknelim/ATonGout.java create mode 100644 src/test/java/ch/heigvd/res/pizza/domain/voknelim/ATonGoutTest.java diff --git a/src/main/java/ch/heigvd/res/pizza/domain/voknelim/ATonGout.java b/src/main/java/ch/heigvd/res/pizza/domain/voknelim/ATonGout.java new file mode 100644 index 0000000..56476f6 --- /dev/null +++ b/src/main/java/ch/heigvd/res/pizza/domain/voknelim/ATonGout.java @@ -0,0 +1,21 @@ +package ch.heigvd.res.pizza.domain.voknelim; + +import ch.heigvd.res.pizza.domain.IProduct; + +import java.math.BigDecimal; + +public class ATonGout implements IProduct { + + public final static String NAME = "ATonGout"; + public final static BigDecimal PRICE = new BigDecimal(19.0); + + @Override + public String getName() { + return NAME; + } + + @Override + public BigDecimal getPrice() { + return PRICE; + } +} diff --git a/src/test/java/ch/heigvd/res/pizza/domain/voknelim/ATonGoutTest.java b/src/test/java/ch/heigvd/res/pizza/domain/voknelim/ATonGoutTest.java new file mode 100644 index 0000000..5fdae41 --- /dev/null +++ b/src/test/java/ch/heigvd/res/pizza/domain/voknelim/ATonGoutTest.java @@ -0,0 +1,32 @@ +package ch.heigvd.res.pizza.domain.voknelim; + +import ch.heigvd.res.pizza.domain.Pizzaiolo; +import ch.heigvd.res.pizza.protocol.OrderRequest; +import ch.heigvd.res.pizza.protocol.OrderResponse; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ATonGoutTest { + + @Test + void thePriceAndNameForATonGoutShouldBeCorrect() { + ATonGout pizza = new ATonGout(); + assertEquals(pizza.getName(), ATonGout.NAME); + assertEquals(pizza.getPrice(), ATonGout.PRICE); + } + + @Test + void aPizzaioloShouldAcceptAnOrderForATonGout() { + Pizzaiolo mario = new Pizzaiolo(); + String productName = "ch.heigvd.res.pizza.domain.voknelim.ATonGout"; + int numberOfPizzas = 2; + OrderRequest request = new OrderRequest(numberOfPizzas, productName); + OrderResponse response = mario.order(request); + BigDecimal expectedTotalPrice = ATonGout.PRICE.multiply(new BigDecimal(numberOfPizzas)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } + +} \ No newline at end of file