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(); }