public void registerTest() { DBSubscribedUser dbsubscribedUser = DBSubscribedUser.getInstance(); SubscribedUser sub3 = new SubscribedUser("Benny", "aaaa", new ShoppingBasket()); dbsubscribedUser.register(sub3); Session session = new Session(); UserState state = session.getState(); Assert.IsTrue(Equals(state.register("Benny", "aaaa", session), "ERROR: username already exists")); Assert.IsTrue(Equals(state.register("Viva", "Diva", session), "")); Assert.IsTrue(state is Guest); dbsubscribedUser.cleanDB(); }
public void logoutTest() { DBSubscribedUser dbsubscribedUser = DBSubscribedUser.getInstance(); SubscribedUser sub2 = new SubscribedUser("Gal", "Gadot", new ShoppingBasket()); dbsubscribedUser.register(sub2); Session session = new Session(); UserState state = session.getState(); state.login("Gal", "Gadot", session); SubscribedUser user = session.getSubscribedUser(); session.getState().logout(user, session); Assert.IsTrue(session.getState() is Guest); Assert.IsNull(dbsubscribedUser.getloggedInUser("Gal")); dbsubscribedUser.cleanDB(); }
public void loginTest1() { DBSubscribedUser dbsubscribedUser = DBSubscribedUser.getInstance(); SubscribedUser sub1 = new SubscribedUser("Danny", dbsubscribedUser.encryptPassword("Shovevani"), new ShoppingBasket()); dbsubscribedUser.register(sub1); Session session = new Session(); UserState state = session.getState(); try { state.login("bob", "dilan", session); Assert.Fail(); } catch (LoginException) { Assert.IsTrue(true); } }
public void loginTest() { DBSubscribedUser dbsubscribedUser = DBSubscribedUser.getInstance(); SubscribedUser sub1 = new SubscribedUser("Danny", dbsubscribedUser.encryptPassword("Shovevani"), new ShoppingBasket()); dbsubscribedUser.register(sub1); Session session = new Session(); UserState state = session.getState(); Assert.IsTrue(Equals(state.login("bob", "dilan", session), "ERROR: username does not exist")); Assert.IsTrue(Equals(state.login("Danny", "Shovevani", session), "")); Assert.IsTrue(session.getState() is LoggedIn); Session session2 = new Session(); UserState state2 = session2.getState(); Assert.IsTrue(Equals(state.login("Danny", "aaaa", session2), "ERROR: password incorrect")); dbsubscribedUser.cleanDB(); }
public void registerTest1() { DBSubscribedUser dbsubscribedUser = DBSubscribedUser.getInstance(); SubscribedUser sub3 = new SubscribedUser("Benny", "aaaa", new ShoppingBasket()); dbsubscribedUser.register(sub3); Session session = new Session(); UserState state = session.getState(); try { state.register("Benny", "aaaa", session); Assert.Fail(); } catch (RegisterException) { Assert.IsTrue(state is Guest); } }