@Test public void testClearPrimaryBySettingToNull() throws Exception { IGenericTrait unwanted = new ValuedTraitType(AbilityType.Athletics, 4); data.setPrimaryPrerequisite(unwanted); IGenericTrait expected = new ValuedTraitType(null, 1); data.setPrimaryPrerequisite(expected); assertEquals(0, data.getPrerequisites().length); assertNull(data.getPrimaryTraitType()); }
@Test(expected = IllegalArgumentException.class) public void testCannotRemovePrimaryPrerequisite() throws Exception { IGenericTrait expected = new ValuedTraitType(AbilityType.Awareness, 4); data.setPrimaryPrerequisite(expected); data.removePrerequisite(expected); assertEquals(1, data.getPrerequisites().length); assertTrue(ArrayUtilities.containsValue(data.getPrerequisites(), expected)); }
@Test public void testPrimaryPrerequisteComesFirst() throws Exception { IGenericTrait prerequiste = new ValuedTraitType(AbilityType.Athletics, 4); data.addPrerequisite(prerequiste); IGenericTrait primary = new ValuedTraitType(AbilityType.Awareness, 4); data.setPrimaryPrerequisite(primary); assertEquals(2, data.getPrerequisites().length); assertEquals(primary, data.getPrerequisites()[0]); }
@Test public void testChangePrimaryPrerequisiteType() throws Exception { IGenericTrait unwanted = new ValuedTraitType(AbilityType.Athletics, 4); IGenericTrait expected = new ValuedTraitType(AbilityType.Awareness, 4); data.setPrimaryPrerequisite(unwanted); data.setPrimaryPrerequisite(expected); assertEquals(1, data.getPrerequisites().length); assertTrue(ArrayUtilities.containsValue(data.getPrerequisites(), expected)); assertFalse(ArrayUtilities.containsValue(data.getPrerequisites(), unwanted)); assertEquals(expected.getType(), data.getPrimaryTraitType()); }