From 8063de972f4914a7c8c55c2229ef7a0c0b240f0b Mon Sep 17 00:00:00 2001 From: KDVL Date: Wed, 17 Apr 2019 18:52:04 +0200 Subject: [PATCH] add mexicana --- .../pizza/domain/kevindovale/Mexicana.java | 19 ++++++++++++ .../domain/kevindovale/MexicanaTest.java | 31 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/main/java/ch/heigvd/res/pizza/domain/kevindovale/Mexicana.java create mode 100644 src/test/java/ch/heigvd/res/pizza/domain/kevindovale/MexicanaTest.java diff --git a/src/main/java/ch/heigvd/res/pizza/domain/kevindovale/Mexicana.java b/src/main/java/ch/heigvd/res/pizza/domain/kevindovale/Mexicana.java new file mode 100644 index 0000000..68d1904 --- /dev/null +++ b/src/main/java/ch/heigvd/res/pizza/domain/kevindovale/Mexicana.java @@ -0,0 +1,19 @@ +package ch.heigvd.res.pizza.domain.kevindovale; + +import ch.heigvd.res.pizza.domain.IProduct; + +import java.math.BigDecimal; + +public class Mexicana implements IProduct { + + public final static String NAME = "Mexicana Pizza"; + public final static BigDecimal PRICE = new BigDecimal(17); + + public String getName() { + return NAME; + } + + public BigDecimal getPrice(){ + return PRICE; + } +} \ No newline at end of file diff --git a/src/test/java/ch/heigvd/res/pizza/domain/kevindovale/MexicanaTest.java b/src/test/java/ch/heigvd/res/pizza/domain/kevindovale/MexicanaTest.java new file mode 100644 index 0000000..8f7c663 --- /dev/null +++ b/src/test/java/ch/heigvd/res/pizza/domain/kevindovale/MexicanaTest.java @@ -0,0 +1,31 @@ +package ch.heigvd.res.pizza.domain.kevindovale; + +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.*; + +class MexicanaTest { + + @Test + void thePriceAndNameForMexicanaShouldBeCorrect() { + Mexicana pizza = new Mexicana(); + assertEquals(pizza.getName(), Mexicana.NAME); + assertEquals(pizza.getPrice(), Mexicana.PRICE); + } + + @Test + void aPizzaioloShouldAcceptAnOrderForMexicana() { + Pizzaiolo mario = new Pizzaiolo(); + String productName = "ch.heigvd.res.pizza.domain.kevindovale.Mexicana"; + int numberOfPizzas = 2; + OrderRequest request = new OrderRequest(numberOfPizzas, productName); + OrderResponse response = mario.order(request); + BigDecimal expectedTotalPrice = Mexicana.PRICE.multiply(new BigDecimal(numberOfPizzas)); + assertEquals(expectedTotalPrice, response.getTotalPrice()); + } +} \ No newline at end of file