-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogOutTest.java
49 lines (34 loc) · 1013 Bytes
/
LogOutTest.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
package STassgn;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import junitparams.JUnitParamsRunner;
@RunWith(JUnitParamsRunner.class)
public class LogOutTest {
DisplayUtilities duMock;
HotelBookingSystem hbs;
@Before
public void setup() {
duMock = mock(DisplayUtilities.class);
hbs = new HotelBookingSystem();
hbs.setDu(duMock);
}
@Test
public void testLogout_UserLoggedIn() {
User user = new User("John", "VIP", false);
hbs.setUser(user);
hbs.logout();
verify(duMock).showToScreen("Logout successful\n\n");
assertEquals(null, hbs.getUser());
}
@Test
public void testLogout_UserNotLoggedIn() {
hbs.setUser(null);
hbs.logout();
verify(duMock).showToScreen("User is not logged in!\n\n");
assertEquals(null, hbs.getUser());
}
}