DataHandlerForTestsTest updated
[staff/due1/sed-hs15-srs-purple.git] / src / test / java / ch / bfh / ti / srs / datahandler / DataHandlerForTestsTest.java
index bb3737c..bfdb9f2 100644 (file)
@@ -8,6 +8,8 @@
 package ch.bfh.ti.srs.datahandler;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
@@ -308,4 +310,71 @@ public class DataHandlerForTestsTest {
 
                assertEquals(3, allReservations.size());
        }
+       
+       @Test
+       public void editUserTest() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               dh.addUser(new User("TestUser1","pass1"));
+               assertTrue(dh.editUser(new User("TestUser1","pass1")));
+       }
+
+       @Test(expected = IllegalArgumentException.class)
+       public void editUserException1Test() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               
+               dh.editUser(null);
+       }
+       
+       @Test
+       public void editUserException2Test() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               dh.addUser(new User("TestUser1","pass1"));
+               assertFalse(dh.editUser(new User("TestUser2","pass1")));
+       }
+       
+       @Test
+       public void deleteResourceTest() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               
+               Resource res = new Resource("Room1", "Testroom");
+               dh.addResource(res);
+               dh.deleteResource(res);
+       }
+       
+       @Test(expected = IllegalArgumentException.class)
+       public void deleteResourceExceptionTest() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               
+               dh.deleteResource(null);
+       }
+
+       @Test
+       public void deleteResourceException1Test() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               
+               dh.deleteResource(new Resource("Room1", "Testroom"));
+       }
+
+       @Test
+       public void editResourceTest() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               
+               Resource res = new Resource("Room1", "Testroom");
+               dh.addResource(res);
+               dh.editResource(res);
+       }
+       
+       @Test(expected = IllegalArgumentException.class)
+       public void editResourceExceptionTest() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               
+               dh.editResource(null);
+       }
+
+       @Test
+       public void editResourceException1Test() throws Exception {
+               DataHandlerForTests dh = new DataHandlerForTests();
+               
+               dh.editResource(new Resource("Room1", "Testroom"));
+       }
 }