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