Browse files

Added test for state equality after changing usernames

  • Loading branch information...
1 parent 99f860b commit 4a85d43ba893b19024dd6d4f817b028fcbb7674d @ahnguyen ahnguyen committed Dec 2, 2011
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/test/UpdateUserNameCommandTest.java
View
12 src/test/UpdateUserNameCommandTest.java
@@ -25,11 +25,11 @@ public void setUp ( ) {
try {
_firstUser = new CTEUser("firstUser", InetAddress.getLocalHost(), Color.BLACK);
_addFirstUserCommand = new AddUserCommand(_firstUser);
- _changeFirstUserCommand = new UpdateUserNameCommand(_firstUser, "firstUserChanged");
+ _changeFirstUserCommand = new UpdateUserNameCommand(_firstUser, "changedFirstUser");
_secondUser = new CTEUser("secondUser", InetAddress.getLocalHost(), Color.BLACK);
_addSecondUserCommand = new AddUserCommand(_secondUser);
- _changeSecondUserCommand = new UpdateUserNameCommand(_secondUser, "secondUserChanged");
+ _changeSecondUserCommand = new UpdateUserNameCommand(_secondUser, "changedSecondUser");
}
catch (Exception e) { fail(e.getMessage()); }
}
@@ -49,7 +49,9 @@ public void testUpdateUserNameExecute ( ) {
//Change first user's name and perform "appropriate" assertion(s)
_changeFirstUserCommand.execute(_docController);
assertEquals(1, _docController.getUsers().size());
- assertEquals(userManager.getUser(_firstUser.getUniqueID()), _firstUser);
+ CTEUser changedFirstUser = userManager.getUser(_firstUser.getUniqueID());
+ assertEquals(changedFirstUser, _firstUser); //referential equality
+ assertEquals("changedFirstUser", changedFirstUser.getName()); //state equality
//Add second user
_addSecondUserCommand.execute(_docController);
@@ -59,7 +61,9 @@ public void testUpdateUserNameExecute ( ) {
//Change second user's name and perform "appropriate" assertion(s)
_changeSecondUserCommand.execute(_docController);
assertEquals(2, _docController.getUsers().size());
- assertEquals(userManager.getUser(_secondUser.getUniqueID()), _secondUser);
+ CTEUser changedSecondUser = userManager.getUser(_secondUser.getUniqueID());
+ assertEquals(changedSecondUser, _secondUser); //referential equality
+ assertEquals("changedSecondUser", changedSecondUser.getName()); //state equality
}
catch (Exception e) { fail(e.getMessage()); }
}//End testUpdateUserNameExecute()

0 comments on commit 4a85d43

Please sign in to comment.