/** * Test method for {@link * edu.ncsu.csc216.flix_2.customer.MovieCustomerAccountSystem#isCustomerLoggedIn()} . */ @Test public void testIsCustomerLoggedIn() { // Create a new customer to work with system.login(admin, admin); system.addNewCustomer("user", "user", 10); system.logout(); // test if the customer logged in has logged out system.login("user", "user"); assertTrue(system.isCustomerLoggedIn()); system.logout(); assertFalse(system.isCustomerLoggedIn()); }
/** * Test method for {@link * edu.ncsu.csc216.flix_2.customer.MovieCustomerAccountSystem#login(java.lang.String, * java.lang.String)} . */ @Test public void testLogin() { // test exception thrown if customer does not exist try { system.login("user", "password"); fail("No Exception/Didn't catch it)"); } catch (IllegalArgumentException e) { assertFalse(system.isCustomerLoggedIn()); } // test exception thrown if the admin has invalid username or password try { system.login(admin, "password"); fail("No Exception/Didn't catch it)"); } catch (IllegalArgumentException e) { assertFalse(system.isAdminLoggedIn()); } // test exception thrown if a user has not logged out // and another user tries to log in system.login(admin, admin); assertTrue(system.isAdminLoggedIn()); assertFalse(system.isCustomerLoggedIn()); try { system.login("username", "password"); fail("No Exception/Didn't catch it)"); } catch (IllegalStateException e) { assertTrue(system.isAdminLoggedIn()); assertFalse(system.isCustomerLoggedIn()); } system.logout(); // test if admin is logged in system.login(admin, admin); assertTrue(system.isAdminLoggedIn()); system.logout(); // test if a customer is logged in system.login(admin, admin); system.addNewCustomer("user", "user", 10); system.logout(); // System.out.println(system.listAcounts()); system.login("user", "user"); assertTrue(system.isCustomerLoggedIn()); system.logout(); }
/** * Test method for {@link * edu.ncsu.csc216.flix_2.customer.MovieCustomerAccountSystem#MovieCustomerAccountSystem(edu.ncsu.csc216.flix_2.rental_system.RentalManager)} * . */ @Test public void testMovieCustomerAccountSystem() { // check if the variables are initialized properly assertFalse(system.isAdminLoggedIn()); assertFalse(system.isCustomerLoggedIn()); }