public void loginTest() { DBSubscribedUser db = DBSubscribedUser.getInstance(); db.cleanDB(); Session s = new Session(); s.register("etay", "etay"); s.login("etay", "etay"); Assert.AreEqual(db.getloggedInUser("etay"), s.getSubscribedUser()); db.cleanDB(); }
public void getSubscribedUserTest() { DBSubscribedUser db = DBSubscribedUser.getInstance(); Session s = new Session(); s.register("etay", "etay"); Assert.AreNotEqual(db.getSubscribedUser("etay"), null); db.cleanDB(); }
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 db = DBSubscribedUser.getInstance(); db.cleanDB(); Session s = new Session(); s.register("etay", "etay"); s.login("etay", "etay"); if (db.getSubscribedUser("etay") == null) { Assert.Fail(); } s.logout(); Assert.AreEqual(null, db.getloggedInUser("etay")); }
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 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(); }