import java.util.Calendar; import java.util.HashSet; import java.util.Enumeration; import nl.rickvanderzwet.toos.assignment1.Voter; import nl.rickvanderzwet.toos.assignment1.Census; public class CensusTest extends junit.framework.TestCase { public void testEmptyVoteList() { HashSet v = null; Census c = new Census(); assertNull(c.census(v)); } public void testAllPositiveVote() { HashSet v = new HashSet(); v.add(new Voter(true)); v.add(new Voter(true)); v.add(new Voter(true)); v.add(new Voter(true)); Census c = new Census(); assertTrue(c.census(v)); } public void testNegativeVote() { HashSet v = new HashSet(); v.add(new Voter(true)); v.add(new Voter(true)); v.add(new Voter(false)); v.add(new Voter(true)); Census c = new Census(); assertFalse(c.census(v)); } public void testInvalidVoter() { HashSet v = new HashSet(); v.add(new Voter(true)); v.add(new Voter(true)); v.add(new Voter(false)); v.add(null); Census c = new Census(); assertNull(c.census(v)); } public void testDuplicateVote() { HashSet v = new HashSet(); Voter d = new Voter(true); assertTrue(v.add(d)); assertFalse(v.add(d)); } public void testUnusedVote() { HashSet v = new HashSet(); v.add(new Voter(true)); v.add(new Voter(true)); v.add(new Voter(false)); v.add(new Voter()); Census c = new Census(); assertNull(c.census(v)); } }