Verify that the randomize function in BioSet is functioning properly.
()
| 88 | * is functioning properly. |
| 89 | */ |
| 90 | @Test |
| 91 | public void testRandomize() |
| 92 | { |
| 93 | final int[] BASE_AGE = {15, 35, 53, 70}; |
| 94 | final int[] MAX_AGE = {34, 52, 69, 110}; |
| 95 | |
| 96 | final BioSet currBioSet = SettingsHandler.getGameAsProperty().get().getBioSet(); |
| 97 | final PlayerCharacter pc = getCharacter(); |
| 98 | final Race human = new Race(); |
| 99 | human.setName("NAME_Human"); |
| 100 | human.put(StringKey.KEY_NAME, "Human"); |
| 101 | pc.setRace(human); |
| 102 | for (int ageCat = 0; ageCat < MAX_AGE.length; ageCat++) |
| 103 | { |
| 104 | currBioSet.randomize("AGECAT" + ageCat, pc); |
| 105 | final int age = (Integer) getAge(pc); |
| 106 | //System.out.println("Age for cat " + ageCat + " is " + age + "."); |
| 107 | assertTrue( |
| 108 | (age >= BASE_AGE[ageCat] && age <= MAX_AGE[ageCat]), "Generated age " + age + " is not between " |
| 109 | + BASE_AGE[ageCat] + " and " + MAX_AGE[ageCat]); |
| 110 | } |
| 111 | LocaleDependentTestCase.before(Locale.US); |
| 112 | currBioSet.randomize("AGE.HT.WT.EYES.HAIR.SKIN", pc); |
| 113 | LocaleDependentTestCase.after(); |
| 114 | Integer height = HeightCompat.getCurrentHeight(pc.getCharID()); |
| 115 | assertTrue((height >= 58 && height <= 78), |
| 116 | "Generated height " + height + " is not in required range."); |
| 117 | assertTrue((pc.getDisplay().getWeight() >= 120 && pc |
| 118 | .getDisplay().getWeight() <= 280), "Generated weight " + pc.getDisplay().getWeight() |
| 119 | + " is not in required range."); |
| 120 | assertEquals("Blue", pc.getSafeStringFor(PCStringKey.EYECOLOR), "Generated eye colour " + pc.getSafeStringFor(PCStringKey.EYECOLOR) |
| 121 | + " is not valid."); |
| 122 | assertTrue( |
| 123 | ("Blond".equals(HairColorCompat.getCurrentHairColor(pc.getCharID())) |
| 124 | || "Brown".equals( |
| 125 | HairColorCompat.getCurrentHairColor(pc.getCharID()))), |
| 126 | "Generated hair colour " |
| 127 | + HairColorCompat.getCurrentHairColor(pc.getCharID()) |
| 128 | + " is not valid."); |
| 129 | String skinColor = (String) ChannelUtilities |
| 130 | .readControlledChannel(pc.getCharID(), CControl.SKINCOLORINPUT); |
| 131 | assertTrue(("Pasty".equals(skinColor) || "Tanned".equals(skinColor)), |
| 132 | "Generated skin colour " + skinColor + " is not valid."); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Test the age set |
nothing calls this directly
no test coverage detected