forked from john-bai/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisitorTest.java
More file actions
53 lines (45 loc) · 1.25 KB
/
Copy pathVisitorTest.java
File metadata and controls
53 lines (45 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package designpatterns;
import java.util.List;
import java.util.ArrayList;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author jtherrell
*/
public class VisitorTest {
private List<Equipment> parts;
private Equipment chassis;
public VisitorTest() {
parts = new ArrayList<Equipment>();
parts.add(new FloppyDisk("iFloppy", 10));
parts.add(new FloppyDisk("MyFloppy", 5));
parts.add(new Card("iCard", 100));
parts.add(new Card("MyCard", 50));
chassis = new Chassis("Chassis", 1000, parts);
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void testInventoryVisitor() {
List<Equipment> inventory = new ArrayList<Equipment>();
InventoryVisitor visitor = new InventoryVisitor(inventory);
chassis.accept(visitor);
int expResult = 5;
int result = inventory.size();
assertEquals(expResult, result);
}
@Test
public void testPriceVisitor() {
PricingVisitor priceVisitor = new PricingVisitor();
chassis.accept(priceVisitor);
double expResult = 1165;
double result = priceVisitor.total();
assertEquals(expResult, result, 0);
}
}