/** * Test method for {@link * edu.ncsu.csc216.flix_2.customer.MovieCustomerAccountSystem#listAcounts()} . */ @Test public void testListAcounts() { // adding a new customer and listing the accounts assertEquals("", system.listAcounts()); system.login(admin, admin); system.addNewCustomer("user", "password", 10); system.logout(); assertEquals("user\n", system.listAcounts()); // adding two more customers to check if // it lists the usernames is lexicographic order assertEquals("user\n", system.listAcounts()); system.login(admin, admin); system.addNewCustomer("realUser", "password", 10); system.addNewCustomer("theRealUser", "password", 10); system.logout(); assertEquals("realUser\ntheRealUser\nuser\n", system.listAcounts()); }
/** * Test method for {@link * edu.ncsu.csc216.flix_2.customer.MovieCustomerAccountSystem#addNewCustomer(java.lang.String, * java.lang.String, int)} . */ @Test public void testAddNewCustomer() { // test exception thrown if admin is not logged in // and we try to create a new customer assertEquals("", system.listAcounts()); try { system.addNewCustomer("user", "password", 10); fail("No Exception/Didn't catch it)"); } catch (IllegalStateException e) { assertEquals("", system.listAcounts()); } assertEquals("", system.listAcounts()); // creating a new user system.login(admin, admin); // test if exceptions are propogated when // username or password is null try { system.addNewCustomer(null, "user1", 10); fail("No Exception/Didn't catch it)"); } catch (Exception e) { assertEquals("", system.listAcounts()); } system.logout(); // test creating and adding a new customer assertEquals("", system.listAcounts()); system.login(admin, admin); system.addNewCustomer("user", "user", 10); system.logout(); assertEquals("user\n", system.listAcounts()); }