//TODO: use more unique identifier than layer ID for scheme mapping key
@Test
public void testColourScheme() throws Exception {
//add and remove some layers, and make sure the colours are proper
Map map = MapTests.createDefaultMap("test", 2, true, new Dimension(10,10)); //$NON-NLS-1$
IGeoResource resource1 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
"type1", 4), false); //$NON-NLS-1$
IGeoResource resource2 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
"type2", 4), false); //$NON-NLS-1$
IGeoResource resource3 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
"type3", 4), false); //$NON-NLS-1$
IGeoResource resource4 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
"type4", 4), false); //$NON-NLS-1$
IGeoResource resource5 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
"type5", 4), false); //$NON-NLS-1$
IGeoResource resource6 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
"type6", 4), false); //$NON-NLS-1$
assertEquals(1, map.getMapLayers().size());
assertEquals(8, map.getColourScheme().getColourPalette().getMaxColors());
List<IGeoResource> resources = new ArrayList<IGeoResource>();
resources.add(resource1);
assertTrue(coloursAreUnique(map.getColourScheme()));
addLayer(resource1, map);
assertEquals(2, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
removeLayer(map, 0);
assertEquals(1, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
addLayer(resource2, map);
assertEquals(2, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
addLayer(resource3, map);
assertEquals(3, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
addLayer(resource4, map);
assertEquals(4, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
addLayer(resource5, map);
assertEquals(5, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
removeLayer(map, 2);
assertEquals(4, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
addLayer(resource6, map);
assertEquals(5, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
addLayer(resource3, map);
assertEquals(6, map.getMapLayers().size());
assertTrue(coloursAreUnique(map.getColourScheme()));
showDefaultColours(map);
}