-
Notifications
You must be signed in to change notification settings - Fork 0
/
PositionsTest.java
83 lines (65 loc) · 1.92 KB
/
PositionsTest.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import org.junit.*;
import static org.junit.Assert.*;
/**
* PositionsTest teste le traitement Positions.
*
* @author Xavier Crégut <[email protected]>
*/
public class PositionsTest extends TraitementTestAbstrait {
private PositionsAbstrait positions;
private Position p1, p2;
@Override
protected PositionsAbstrait nouveauTraitement() {
return new FabriqueTraitementConcrete().positions();
}
@Override
public void setUp() {
try {
super.setUp();
this.positions = nouveauTraitement();
this.p1 = new Position(1, 2);
this.p2 = new Position(-3, 5);
this.positions.gererDebutLot("Lot1");
this.positions.traiter(p1, 11);
this.positions.traiter(p2, 7);
this.positions.traiter(p1, 3);
this.positions.gererFinLot("Lot1");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testerChainage() {
testerChainage(true, true);
}
@Test
public void testerNominalPositions() {
assertSame(p1, this.positions.position(0));
assertSame(p2, this.positions.position(1));
assertSame(p1, this.positions.position(2));
}
@Test
public void testerNominalFrequence() {
assertEquals(2, this.positions.frequence(this.p1));
assertEquals(1, this.positions.frequence(this.p2));
assertEquals(0, this.positions.frequence(new Position(15, 1)));
}
@Test
public void testerNominalFrequenceNouvellesPositions() {
assertEquals(2, this.positions.frequence(new Position(1, 2)));
assertEquals(1, this.positions.frequence(new Position(-3, 5)));
assertEquals(0, this.positions.frequence(new Position(15, 1)));
}
@Test
public void testerLimitereurFrequence() {
assertEquals(0, this.positions.frequence(null));
}
@Test(expected=IndexOutOfBoundsException.class)
public void testerErreurIndexTropGrand() {
assertSame(p1, this.positions.position(3));
}
@Test(expected=IndexOutOfBoundsException.class)
public void testerErreurIndexTropPetit() {
this.positions.position(-1);
}
}