setPasswordTest()
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / core / UserTest.java
CommitLineData
7f912ebe
M
1/*\r
2 * Copyright (c) 2015 Berner Fachhochschule, Switzerland.\r
3 *\r
4 * Project Smart Reservation System.\r
5 *\r
6 * Distributable under GPL license. See terms of license at gnu.org.\r
7 */\r
8package ch.bfh.ti.srs.core;\r
9\r
10import static org.junit.Assert.*;\r
11\r
12import java.util.Set;\r
13\r
14import org.junit.BeforeClass;\r
15import org.junit.Test;\r
16\r
17public class UserTest {\r
d6a2afc6 18 private Set<User> userList;\r
7f912ebe
M
19 User TestUser;\r
20 \r
21 @BeforeClass\r
22 public static void setUpBeforeClass() throws Exception {\r
23 \r
24 }\r
25\r
26 @Test\r
d6a2afc6
M
27 public void createUserTest() {\r
28 TestUser = new User("TestUser","pass");\r
7f912ebe
M
29 assertEquals("TestUser", TestUser.getUserName());\r
30 }\r
31 \r
32 @Test\r
d6a2afc6
M
33 public void checkPasswordTest() {\r
34 assertTrue(TestUser.checkPassword("pass"));\r
35 assertFalse(TestUser.checkPassword("notmypass"));\r
36 }\r
37 \r
38 @Test\r
39 public void changePasswordTest() {\r
40 assertTrue(TestUser.checkPassword("pass"));\r
41 TestUser.changePassword("newpass");\r
42 assertTrue(TestUser.checkPassword("newpass"));\r
43 assertFalse(TestUser.checkPassword("pass"));\r
44 assertFalse(TestUser.checkPassword("notmypass"));\r
45 }\r
46 \r
47 @Test\r
48 public void setMailTest() {\r
49 String goodMail = "grosm9@bfh.ch";\r
50 String wrongMail1 = "ioajfd.ch";\r
51 String wrongMail2 = "asjdfh@fds";\r
52 \r
53 assertTrue(TestUser.setMail(goodMail));\r
54 assertFalse(TestUser.setMail(wrongMail1));\r
55 assertFalse(TestUser.setMail(wrongMail2));\r
56 }\r
57 \r
58 public void getMailTest() {\r
59 String mail = "grosm9@bfh.ch";\r
60 \r
61 TestUser.setMail(mail);\r
62 assertEquals(mail, TestUser.getMail());\r
7f912ebe
M
63 }\r
64\r
65}\r