forked from john-bai/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStateTest.java
More file actions
56 lines (46 loc) · 1.12 KB
/
Copy pathStateTest.java
File metadata and controls
56 lines (46 loc) · 1.12 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
54
55
56
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package designpatterns;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author jtherrell
*/
public class StateTest {
private TCPConnection connection;
public StateTest() {
connection = new TCPConnection();
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void hello() {
assertEquals(TCPClosed.class, connection.state().getClass());
}
@Test
public void testActiveOpen() {
connection.activeOpen();
assertEquals(TCPEstablished.class, connection.state().getClass());
}
@Test
public void testPassiveOpen() {
connection.passiveOpen();
assertEquals(TCPListen.class, connection.state().getClass());
}
@Test
public void testClose() {
connection.activeOpen();
connection.close();
assertEquals(TCPListen.class, connection.state().getClass());
}
@Test
public void testSend() {
connection.passiveOpen();
connection.send();
assertEquals(TCPEstablished.class, connection.state().getClass());
}
}