[306] | 1 | package tests;
|
---|
| 2 |
|
---|
| 3 | import static org.junit.Assert.assertEquals;
|
---|
| 4 | import static org.junit.Assert.assertFalse;
|
---|
| 5 | import static org.junit.Assert.assertTrue;
|
---|
| 6 |
|
---|
| 7 | import org.junit.Test;
|
---|
| 8 |
|
---|
| 9 | import onetomany.bargainingchipsgame.Chip;
|
---|
| 10 | import onetomany.bargainingchipsgame.Stack;
|
---|
| 11 |
|
---|
| 12 | public class StackTest
|
---|
| 13 | {
|
---|
| 14 |
|
---|
| 15 | @Test
|
---|
| 16 | public void testConstructor()
|
---|
| 17 | {
|
---|
| 18 | Stack s = new Stack("Green", 7.0, 5);
|
---|
| 19 |
|
---|
| 20 | assertEquals(s.getColor(), "Green");
|
---|
| 21 | assertEquals(s.getChip(), new Chip("Green"));
|
---|
| 22 | assertEquals(s.getTotalPrice(), 35.0, 0.0);
|
---|
| 23 | assertEquals(s.getUnitPrice(), 7.0, 0.0);
|
---|
| 24 |
|
---|
| 25 | Stack t = new Stack("Green", 4.0, 9);
|
---|
| 26 | Stack u = new Stack("Blue", 2.0, 15);
|
---|
| 27 |
|
---|
| 28 | assertTrue(s.hasSameColorAs(t));
|
---|
| 29 | assertFalse(s.hasSameColorAs(u));
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | @Test
|
---|
| 33 | public void testAggregationSymmetry()
|
---|
| 34 | {
|
---|
| 35 | Stack s = new Stack("Red", 9.0, 3);
|
---|
| 36 | Stack t = new Stack ("Red", 4.0, 2);
|
---|
| 37 |
|
---|
| 38 | Stack sPlust = s.aggregateWith(t);
|
---|
| 39 | System.out.println(s + " + " + t + " = " + sPlust);
|
---|
| 40 |
|
---|
| 41 | Stack tPluss = t.aggregateWith(s);
|
---|
| 42 | System.out.println(t + " + " + s + " = " + tPluss);
|
---|
| 43 |
|
---|
| 44 | assertEquals(sPlust.getChip(), tPluss.getChip());
|
---|
| 45 | assertEquals(sPlust.getQuantity(), tPluss.getQuantity());
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | }
|
---|