Skip to content

Instantly share code, notes, and snippets.

@AnnaBoro
Created February 12, 2016 14:20
Show Gist options
  • Save AnnaBoro/cb294c9265946eb5d543 to your computer and use it in GitHub Desktop.
Save AnnaBoro/cb294c9265946eb5d543 to your computer and use it in GitHub Desktop.
check shop discount
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