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
index caf2ed8..d1b5656 100644 (file)
@@ -7,32 +7,69 @@
  */\r
 package ch.bfh.ti.srs.core;\r
 \r
-import static org.junit.Assert.*;\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertTrue;\r
 \r
-import java.util.Set;\r
-\r
-import org.junit.BeforeClass;\r
 import org.junit.Test;\r
 \r
 public class UserTest {\r
-       private Set<User> userList = new Set<>();\r
-       User TestUser;\r
-       \r
-       @BeforeClass\r
-       public static void setUpBeforeClass() throws Exception {\r
-               \r
+\r
+       @Test\r
+       public void createUserTest() {\r
+               User testUser = new User("TestUser", "pass");\r
+               assertEquals("TestUser", testUser.getUserName());\r
        }\r
 \r
        @Test\r
-       public void CreateUserTest() {\r
-               TestUser = new User(TestUser,"1234");\r
-               assertEquals("TestUser", TestUser.getUserName());\r
+       public void checkPasswordTest() {\r
+               User testUser = new User("TestUser", "pass");\r
+               assertTrue(testUser.checkPassword("pass"));\r
+               assertFalse(testUser.checkPassword("notmypass"));\r
        }\r
-       \r
+\r
        @Test\r
-       public void CheckPasswordTest() {\r
-               assertTrue(TestUser.checkPassword("1234"));\r
-               assertFalse(TestUser.checkPassword("4321"));\r
+       public void changePasswordTest() {\r
+               User testUser = new User("TestUser", "pass");\r
+               assertTrue(testUser.checkPassword("pass"));\r
+               testUser.changePassword("newpass");\r
+               assertTrue(testUser.checkPassword("newpass"));\r
+               assertFalse(testUser.checkPassword("pass"));\r
+               assertFalse(testUser.checkPassword("notmypass"));\r
        }\r
 \r
+       @Test\r
+       public void setMailTest() {\r
+               User testUser = new User("TestUser", "pass");\r
+               String goodMail = "grosm9@bfh.ch";\r
+               String wrongMail1 = "ioajfd.ch";\r
+               String wrongMail2 = "asjdfh@fds";\r
+\r
+               assertTrue(testUser.setMail(goodMail));\r
+               assertFalse(testUser.setMail(wrongMail1));\r
+               assertFalse(testUser.setMail(wrongMail2));\r
+       }\r
+\r
+       @Test\r
+       public void getMailTest() {\r
+               User testUser = new User("TestUser", "pass");\r
+               String mail = "grosm9@bfh.ch";\r
+\r
+               testUser.setMail(mail);\r
+               assertEquals(mail, testUser.getMail());\r
+       }\r
+\r
+       @Test\r
+       public void setAndGetNameTest() {\r
+               User testUser = new User("TestUser", "pass");\r
+               testUser.setName("Tester");\r
+               assertEquals("Tester",testUser.getName());\r
+       }\r
+\r
+       @Test\r
+       public void setAndGetLastnameTest() {\r
+               User testUser = new User("TestUser", "pass");\r
+               testUser.setLastname("Dummy");\r
+               assertEquals("Dummy", testUser.getLastname());\r
+       }\r
 }\r