forked from john-bai/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObserverTest.java
More file actions
44 lines (38 loc) · 1.03 KB
/
Copy pathObserverTest.java
File metadata and controls
44 lines (38 loc) · 1.03 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
/*
* 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 ObserverTest {
public ObserverTest() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void hello() {
Log log = new Log();
Subject subject = new Subject("Original Title", log);
ObserverA obA = new ObserverA(subject);
ObserverB obB = new ObserverB(subject);
ObserverC obC = new ObserverC(subject);
subject.attach(obA);
subject.attach(obB);
subject.attach(obC);
subject.setTitle("Update Title");
String expResult = "notifying ObserverA" + "\n"
+ "ObserverA notified!" + "\n"
+ "notifying ObserverB" + "\n"
+ "ObserverB notified!" + "\n"
+ "notifying ObserverC" + "\n"
+ "ObserverC notified!" + "\n";
String result = log.toString();
assertEquals(expResult, result);
}
}