/*
	cursus - Race series management program
	Copyright 2011  Simon Arlott

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package eu.lp0.cursus.test.util;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.junit.Assert;

import eu.lp0.cursus.db.data.Pilot;
import eu.lp0.cursus.db.data.Race;
import eu.lp0.cursus.scoring.Scores;

public class RaceSummaryAssertUtil {
	private final Map<Pilot, Integer> actualRacePoints;

	private final Set<Pilot> expectedPilots = new HashSet<Pilot>();
	private final int expectedPilotCount;
	private boolean done = false;

	public RaceSummaryAssertUtil(Scores scores, Race race) {
		expectedPilotCount = scores.getPilots().size();
		actualRacePoints = scores.getRacePoints(race);
	}

	public void assertPilot(Pilot pilot, int expectedPoints) {
		Assert.assertFalse(done);

		Assert.assertEquals("Race points mismatch for " + pilot.getName(), expectedPoints, (int)actualRacePoints.get(pilot)); //$NON-NLS-1$
		Assert.assertTrue("Pilot " + pilot.getName() + " already specified", expectedPilots.add(pilot)); //$NON-NLS-1$ //$NON-NLS-2$
	}

	public void assertDone() {
		Assert.assertFalse(done);

		Assert.assertEquals(expectedPilotCount, expectedPilots.size());
		done = true;
	}
}
@@ -745,22 +745,51 @@
 va.util.
-HashSe
+LinkedHashSet;%0Aimport java.util.Lis
 t;%0Aimpor
@@ -1053,17 +1053,16 @@
 Points;%0A
-%0A
 %09private
@@ -1068,18 +1068,19 @@
 e final 
-Se
+Lis
 t%3CPilot%3E
@@ -1084,45 +1084,59 @@
 ot%3E 
-expectedPilots = new HashSet%3C
+actualRaceOrder;%0A%0A%09private final int expected
 Pilot
-%3E()
+s
 ;%0A%09p
@@ -1152,30 +1152,65 @@
 nal 
-int expectedPilotCount
+Set%3CPilot%3E expectedRaceOrder = new LinkedHashSet%3CPilot%3E()
 ;%0A%09p
@@ -1312,21 +1312,17 @@
 tedPilot
-Count
+s
  = score
@@ -1392,16 +1392,63 @@
 (race);%0A
+%09%09actualRaceOrder = scores.getRaceOrder(race);%0A
 %09%7D%0A%0A%09pub
@@ -1745,22 +1745,25 @@
 expected
-Pilots
+RaceOrder
 .add(pil
@@ -1896,13 +1896,9 @@
 ilot
-Count
+s
 , ex
@@ -1907,19 +1907,169 @@
 cted
-Pilots.size
+RaceOrder.size());%0A%09%09Assert.assertEquals(expectedPilots, actualRaceOrder.size());%0A%09%09Assert.assertArrayEquals(expectedRaceOrder.toArray(), actualRaceOrder.toArray
 ());

add additional race order checking