12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- public class ProductTest
- {
- Product product;
-
- @Test
- public void getNameTest(){
- product = new Product("water", 1005, 1.00, 15);
- String expected = "water";
- String actual = product.getName();
- assertEquals(expected, actual);
- }
-
- @Test
- public void getIdTest(){
- product = new Product("water", 1005, 1.00, 15);
- int expected = 1005;
- int actual = product.getId();
- assertEquals(expected, actual);
- }
-
- @Test
- public void getSetPriceTest(){
- product = new Product("water", 1005, 1.00, 15);
- product.setPrice(3.55);
- double expected = 3.55;
- double actual = product.getPrice();
- assertEquals(expected, actual, .01);
- }
-
- @Test
- public void getQuantity(){
- product = new Product("water", 1005, 1.00, 15);
- int expected = 15;
- int actual = product.getQuantity();
- assertEquals(expected, actual);
- }
-
- @Test
- public void changePriceTest(){
- product = new Product("water", 1005, 1.00, 15);
- double expected = 2.75;
- product.setPrice(2.75);
- double actual = product.getPrice();
- assertEquals(expected, actual, .01);
- }
-
- @Test
- public void addQuantityTest(){
- product = new Product("water", 1005, 1.00, 15);
- int expected = 19 ;
- product.addQuantity(4);
- int actual = product.getQuantity();
- assertEquals(expected, actual);
- }
-
- public void getValue(){
- product = new Product("water", 1005, 1.00, 15);
- double expected = 15.00;
- double actual = product.getValue();
- assertEquals(expected, actual, .01);
- }
- }
|