source: src/main/java/bargainingchips/tests/StackTest.java@ 315

Last change on this file since 315 was 315, checked in by Tim Baarslag, 5 years ago

package restructure

File size: 1.1 KB
Line 
1package tests;
2
3import static org.junit.Assert.assertEquals;
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertTrue;
6
7import org.junit.Test;
8
9import onetomany.bargainingchipsgame.Chip;
10import onetomany.bargainingchipsgame.Stack;
11
12public 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}
Note: See TracBrowser for help on using the repository browser.