forked from ZipCodeCore/BlueJ.NaiveTicket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TicketMachineTest.java
72 lines (56 loc) · 1.89 KB
/
TicketMachineTest.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
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* The test class TicketMachineTest.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TicketMachineTest
{
/**
* Default constructor for test class TicketMachineTest
*/
public TicketMachineTest()
{
}
@Before
public void setUp()
{
}
@After
public void tearDown()
{
}
@Test
public void insertMoneyTest(){
TicketMachine testTicketMachine = new TicketMachine(4);
testTicketMachine.insertMoney(20);
assertEquals(Integer.valueOf(20), testTicketMachine.getBalance());
}
@Test
public void printTicketTest(){
TicketMachine testTicketMachine = new TicketMachine(13);
assertEquals("Ticket price: 13 cents. Your total is 0.",testTicketMachine.printTicket());
assertEquals(Integer.valueOf(1), testTicketMachine.getTicketNumber());
assertEquals(Integer.valueOf(2), testTicketMachine.incrementTicketNumber());
assertNotEquals(Integer.valueOf(3), testTicketMachine.getTicketNumber());
}
@Test
public void printTicketTest2(){
TicketMachine testTicketMachine = new TicketMachine(40);
assertNotEquals("Ticket price: 13 cents. Your total is 0.", testTicketMachine.printTicket());
assertEquals(Integer.valueOf(1), testTicketMachine.getTicketNumber());
}
@Test
public void incrementTicketNumberTest(){
TicketMachine testTicketMachine = new TicketMachine(40);
for(int i = 0; i < 10; i++){
testTicketMachine.printTicket();
}
assertEquals(Integer.valueOf(10), testTicketMachine.getTicketNumber());
assertNotEquals(Integer.valueOf(9), testTicketMachine.getTicketNumber());
}
}