package ie.votail.model.factory.test;

import ie.votail.model.ElectionConfiguration;
import ie.votail.model.ElectoralScenario;
import ie.votail.model.factory.BallotBoxFactory;
import ie.votail.model.factory.ScenarioFactory;
import ie.votail.model.factory.ScenarioList;

import java.util.logging.Logger;

import org.junit.Test;

import election.tally.BallotCounting;
import election.tally.Constituency;

public class VotailSystemTest {
  @Test
  public void twoCandidateTest() {
    
    ScenarioFactory scenarioFactory = new ScenarioFactory();
    BallotCounting ballotCounting = new BallotCounting();
    Logger logger = Logger.getLogger(BallotBoxFactory.LOG_FILENAME);
    
    final int candidates = 20;
    final int seats = 3;
    ScenarioList scenarios = scenarioFactory.find(candidates,seats);
    
    for (ElectoralScenario scenario: scenarios) {
      logger.info(scenario.toString());
      final int scope = 5;
      BallotBoxFactory ballotBoxFactory = new BallotBoxFactory();
      ElectionConfiguration electionConfiguration 
        = ballotBoxFactory.extractBallots(scenario, scope);
      Constituency constituency = electionConfiguration.getConstituency();
      logger.info(constituency.toString());
      logger.info(electionConfiguration.toString());
      ballotCounting.setup(constituency);
      ballotCounting.load(electionConfiguration);
      ballotCounting.count();
      logger.info(ballotCounting.getResults());
    }
  }
}

@@ -1,8 +1,65 @@
+// 2010-11, Dermot Cochran, IT University of Copenhagen%0A%0A
 package 
@@ -85,24 +85,60 @@
 tory.test;%0A%0A
+import org.testng.annotations.Test;%0A
 import ie.vo
@@ -394,32 +394,8 @@
 r;%0A%0A
-import org.junit.Test;%0A%0A
 impo
@@ -501,18 +501,16 @@
 t %7B%0A
-  
+%09
 @Test%0A
-  
+%09
 publ
@@ -521,38 +521,55 @@
 oid 
-twoCandidateTest() %7B%0A    %0A    
+fullSystemsTest() %7B%0A%0A%09%09final int scope = 5;%0A%0A%09%09
 Scen
@@ -621,20 +621,18 @@
 tory();%0A
-    
+%09%09
 BallotCo
@@ -677,20 +677,18 @@
 ting();%0A
-    
+%09%09
 Logger l
@@ -748,23 +748,16 @@
 E);%0A
-    %0A    final 
+%0A%09%09for (
 int 
@@ -773,41 +773,95 @@
 s = 
-20;%0A    final int seats = 3;%0A    
+6; candidates %3C= 50; candidates++) %7B%0A%09%09%09for (int seats = 3; seats %3C= 5; seats++) %7B%0A%09%09%09%09
 Scen
@@ -877,17 +877,20 @@
 scenario
-s
+List
  = scena
@@ -920,16 +920,23 @@
 tes,
+%0A%09%09%09%09%09%09
 seats);%0A
     
@@ -935,17 +935,13 @@
 s);%0A
-    %0A    
+%0A%09%09%09%09
 for 
@@ -967,16 +967,17 @@
 scenario
+ 
 : scenar
@@ -982,19 +982,21 @@
 ario
-s) %7B%0A      
+List) %7B%0A%09%09%09%09%09
 logg
@@ -1029,41 +1029,13 @@
 ));%0A
-      final int scope = 5;%0A      
+%09%09%09%09%09
 Ball
@@ -1090,22 +1090,21 @@
 tory();%0A
-      
+%09%09%09%09%09
 Election
@@ -1143,17 +1143,8 @@
 ion 
-%0A        
 = ba
@@ -1157,16 +1157,24 @@
 xFactory
+%0A%09%09%09%09%09%09%09
 .extract
@@ -1199,22 +1199,21 @@
 scope);%0A
-      
+%09%09%09%09%09
 Constitu
@@ -1253,16 +1253,24 @@
 guration
+%0A%09%09%09%09%09%09%09
 .getCons
@@ -1277,30 +1277,29 @@
 tituency();%0A
-      
+%09%09%09%09%09
 logger.info(
@@ -1324,22 +1324,21 @@
 ing());%0A
-      
+%09%09%09%09%09
 logger.i
@@ -1376,22 +1376,21 @@
 ing());%0A
-      
+%09%09%09%09%09
 ballotCo
@@ -1417,22 +1417,21 @@
 uency);%0A
-      
+%09%09%09%09%09
 ballotCo
@@ -1466,22 +1466,21 @@
 ation);%0A
-      
+%09%09%09%09%09
 ballotCo
@@ -1499,26 +1499,30 @@
 ();%0A
-      logger.info(
+%09%09%09%09%09String results = 
 ball
@@ -1548,19 +1548,96 @@
 ts()
-);%0A    %7D%0A  
+;%0A%09%09%09%09%09logger.info(results);%0A%09%09%09%09%09// TODO compare results with scenario%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09
 %7D%0A%7D%0A

Generalise into a full system test