Beispiel #1
0
 /** Tests: public boolean canChangeVote() method of the Voter class. */
 @Test
 public void testCanChangeVote() {
   Voter v1 = new Voter("david", "123");
   assertTrue(v1.canChangeVote());
   assertTrue(v1.vote(new Vote("a")));
   assertTrue(v1.canChangeVote());
   assertTrue(v1.vote(new Vote("b")));
   assertTrue(v1.canChangeVote());
   assertTrue(v1.vote(new Vote("a")));
   assertTrue(!v1.canChangeVote());
   assertTrue(!v1.vote(new Vote("c")));
 }
Beispiel #2
0
 /** Tests: public Voter(Voter other) method of the Voter class. */
 @Test
 public void testVoter() {
   Voter v1 = new Voter("david", "123");
   v1.vote(new Vote("a"));
   v1.vote(new Vote("a"));
   Voter v2 = new Voter(v1);
   assertEquals(v2.getId(), v1.getId());
   assertEquals(v2.getName(), v1.getName());
   assertEquals(v2.getFirstVoteTime(), v1.getFirstVoteTime());
   assertEquals(v2.getVoterCount(), v1.getVoterCount());
   assertEquals(v2.getVote(), v1.getVote());
   v1.vote(new Vote("b"));
   assertTrue(!v1.canChangeVote());
   assertTrue(v2.canChangeVote());
   v2.vote(new Vote("c"));
   assertEquals(v1.getVote(), new Vote("b"));
   assertEquals(v2.getVote(), new Vote("c"));
 }