Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pizza DuChef with tests #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/ch/heigvd/res/pizza/domain/thierryotto/DuChef.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.pizza.domain.thierryotto;

import ch.heigvd.res.pizza.domain.IProduct;

import java.math.BigDecimal;

public class DuChef implements IProduct {

public final static String NAME = "Du Chef";
public final static BigDecimal PRICE = new BigDecimal(20.0);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ch.heigvd.res.pizza.domain.thierryotto;

import ch.heigvd.res.pizza.domain.IProduct;

import java.math.BigDecimal;

public class QuatreSaisons implements IProduct {

public final static String NAME = "Quatre Saisons";
public final static BigDecimal PRICE = new BigDecimal(21.0);

@Override
public String getName() {
return NAME;
}

@Override
public BigDecimal getPrice() {
return PRICE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ch.heigvd.res.pizza.domain.thierryotto;

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 DuChefTest {

@Test
void thePriceAndNameForDuChefShouldBeCorrect() {
DuChef beer = new DuChef();
assertEquals(beer.getName(), DuChef.NAME);
assertEquals(beer.getPrice(), DuChef.PRICE);
}

@Test
void aPizzaioloShouldAcceptAnOrderForDuChef() {
Pizzaiolo mario = new Pizzaiolo();
String productName = "ch.heigvd.res.pizza.domain.thierryotto.DuChef";
int numberOfPizzas = 2;
OrderRequest request = new OrderRequest(numberOfPizzas, productName);
OrderResponse response = mario.order(request);
BigDecimal expectedTotalPrice = DuChef.PRICE.multiply(new BigDecimal(numberOfPizzas));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package ch.heigvd.res.pizza.domain.thierryotto;

import ch.heigvd.res.pizza.domain.Pizzaiolo;
import ch.heigvd.res.pizza.domain.thierryotto.QuatreSaisons;
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 QuatreSaisonsTest {

@Test
void thePriceAndNameForQuatreSaisonsShouldBeCorrect() {
QuatreSaisons beer = new QuatreSaisons();
assertEquals(beer.getName(), QuatreSaisons.NAME);
assertEquals(beer.getPrice(), QuatreSaisons.PRICE);
}

@Test
void aPizzaioloShouldAcceptAnOrderForQuatreSaisons() {
Pizzaiolo mario = new Pizzaiolo();
String productName = "ch.heigvd.res.pizza.domain.thierryotto.QuatreSaisons";
int numberOfPizzas = 2;
OrderRequest request = new OrderRequest(numberOfPizzas, productName);
OrderResponse response = mario.order(request);
BigDecimal expectedTotalPrice = QuatreSaisons.PRICE.multiply(new BigDecimal(numberOfPizzas));
assertEquals(expectedTotalPrice, response.getTotalPrice());
}

}