Created
February 12, 2016 14:20
-
-
Save AnnaBoro/cb294c9265946eb5d543 to your computer and use it in GitHub Desktop.
check shop discount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package junittests; | |
import static org.junit.Assert.*; | |
import lesson6_9.adapter.mvc.shop.*; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.JUnit4; | |
@RunWith(JUnit4.class) | |
public class ShopTests { | |
private Purchase purchase; | |
private Bird bird1; | |
@Before | |
public void setUp() { | |
purchase = new Purchase(); | |
bird1 = new Eagle(); | |
bird1.setPrice(100); | |
purchase.setBird(bird1); | |
} | |
@Test | |
public void checkDiscount5Percent() { | |
double newPrice = bird1.getPrice() * 0.95; | |
purchase.setDiscount(5); | |
assertTrue(newPrice == purchase.getBird().getPrice()); | |
} | |
@Test | |
public void checkDiscount10Percent() { | |
double newPrice = bird1.getPrice() * 0.90; | |
purchase.setDiscount(10); | |
assertTrue(newPrice == purchase.getBird().getPrice()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment