0f61cf15b59d6cfed66936b25e1ea93c8cd27aba
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / core / DataHandlerForTestsTest.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 org.junit.BeforeClass;
13 import org.junit.Test;
14
15 /**
16 * @author Michael Grossen
17 */
18 public class DataHandlerForTestsTest {
19
20 @Test
21 public void addUserTest() throws Exception{
22 DataHandler dh = new DataHandlerForTests();
23 User testUser = null;
24 try {
25 testUser = new User("TestUser", "pass");
26 } catch (Exception e) {
27 fail("Check UserTest (Exception was thrown by User Cunstructor)!");
28 }
29 dh.addUser(testUser);
30 }
31
32 @Test(expected=IllegalArgumentException.class)
33 public void addIllegalUserTest() throws Exception{
34 DataHandler dh = new DataHandlerForTests();
35 User testUser = null;
36 dh.addUser(testUser);
37 }
38
39 @Test
40 public void findUserTest() throws Exception{
41 DataHandler dh = new DataHandlerForTests();
42 User addedUser = new User("TestUser", "pass");
43 dh.addUser(addedUser);
44 User foundUser = dh.findUser("TestUser");
45 assertEquals(addedUser.getUserName(), foundUser.getUserName());
46 }
47
48 @Test
49 public void findNotAddedUser() throws Exception{
50 DataHandler dh = new DataHandlerForTests();
51 assertEquals(null, dh.findUser("notAddedUser"));
52 User addedUser = new User("TestUser", "pass");
53 dh.addUser(addedUser);
54 assertEquals(null, dh.findUser("otherUser"));
55 }
56
57 }