File tree 2 files changed +7
-13
lines changed
2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change 1
1
package halterman .command ;
2
2
3
- import static org .junit .Assert .*;
4
- import halterman .command .Command ;
5
- import halterman .command .Light ;
6
- import halterman .command .LightOnCommand ;
7
- import halterman .command .Switch ;
8
-
9
- import org .mockito .InjectMocks ;
10
- import org .mockito .Mock ;
11
- import org .mockito .Mockito ;
12
- import org .mockito .MockitoAnnotations ;
13
3
import static org .mockito .Mockito .verify ;
14
4
15
5
import org .junit .Before ;
16
6
import org .junit .Test ;
7
+ import org .mockito .InjectMocks ;
8
+ import org .mockito .Mock ;
9
+ import org .mockito .MockitoAnnotations ;
10
+ import org .mockito .Spy ;
17
11
18
12
public class CommandPatternTest {
19
13
@@ -23,20 +17,20 @@ public class CommandPatternTest {
23
17
@ Mock
24
18
Light light ;
25
19
26
- @ Mock
27
- Command lightsOn ;
20
+ @ Spy
21
+ Command lightsOn = new LightOnCommand ( light ) ;
28
22
29
23
@ Before
30
24
public void setUp () {
31
25
MockitoAnnotations .initMocks (this );
32
26
lightSwitch = new Switch ();
27
+ lightSwitch .setCommand (lightsOn );
33
28
}
34
29
35
30
@ Test
36
31
public void shouldTurnOnLight () {
37
32
lightSwitch .pressButton ();
38
33
39
-
40
34
verify (light ).switchOn ();
41
35
}
42
36
You can’t perform that action at this time.
0 commit comments