Re-enabled tests (after having added rng-tools package on build server).
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / core / UserTest.java
... / ...
CommitLineData
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.assertEquals;\r
11import static org.junit.Assert.assertFalse;\r
12import static org.junit.Assert.assertTrue;\r
13\r
14import org.junit.Test;\r
15\r
16public class UserTest {\r
17\r
18 @Test\r
19 public void createUserTest() {\r
20 User testUser = new User("TestUser", "pass");\r
21 assertEquals("TestUser", testUser.getUserName());\r
22 }\r
23\r
24 @Test\r
25 public void checkPasswordTest() {\r
26 User testUser = new User("TestUser", "pass");\r
27 assertTrue(testUser.checkPassword("pass"));\r
28 assertFalse(testUser.checkPassword("notmypass"));\r
29 }\r
30\r
31 @Test\r
32 public void changePasswordTest() {\r
33 User testUser = new User("TestUser", "pass");\r
34 assertTrue(testUser.checkPassword("pass"));\r
35 testUser.changePassword("newpass");\r
36 assertTrue(testUser.checkPassword("newpass"));\r
37 assertFalse(testUser.checkPassword("pass"));\r
38 assertFalse(testUser.checkPassword("notmypass"));\r
39 }\r
40\r
41 @Test\r
42 public void setMailTest() {\r
43 User testUser = new User("TestUser", "pass");\r
44 String goodMail = "grosm9@bfh.ch";\r
45 String wrongMail1 = "ioajfd.ch";\r
46 String wrongMail2 = "asjdfh@fds";\r
47\r
48 assertTrue(testUser.setMail(goodMail));\r
49 assertFalse(testUser.setMail(wrongMail1));\r
50 assertFalse(testUser.setMail(wrongMail2));\r
51 }\r
52\r
53 @Test\r
54 public void getMailTest() {\r
55 User testUser = new User("TestUser", "pass");\r
56 String mail = "grosm9@bfh.ch";\r
57\r
58 testUser.setMail(mail);\r
59 assertEquals(mail, testUser.getMail());\r
60 }\r
61\r
62 @Test\r
63 public void setAndGetNameTest() {\r
64 User testUser = new User("TestUser", "pass");\r
65 testUser.setName("Tester");\r
66 assertEquals("Tester",testUser.getName());\r
67 }\r
68\r
69 @Test\r
70 public void setAndGetLastnameTest() {\r
71 User testUser = new User("TestUser", "pass");\r
72 testUser.setLastname("Dummy");\r
73 assertEquals("Dummy", testUser.getLastname());\r
74 }\r
75}\r