@Test
public void testReportDeadGenome_WhenReportedAndGenomeIsNotAChild_UpdateFitnessSum() throws Exception {
long oldFitnessSum = genePool.getFitnessSum();
// kill an older genome from a past generation
Genome olderGenome = mock(Genome.class);
int fitnessOfOlderGenome = 10;
when(olderGenome.getFitness()).thenReturn(fitnessOfOlderGenome);
when(olderGenome.getBirthGeneration()).thenReturn(genePool.getCurrentGeneration() - 1);
genePool.reportDeadGenome(olderGenome);
assert genePool.getFitnessSum() == oldFitnessSum - fitnessOfOlderGenome : "If a genome has been reported dead the overall fitness sum should decrease by its fitness";
assert genePool.getNumberOfDeadChildren() == 0;
// now kill the genome from current generation (child)
oldFitnessSum = genePool.getFitnessSum();
Genome genomeFromCurrentGeneration = mock(Genome.class);
int fitnessOfGenomeFromCurrentGeneration = 8;
when(genomeFromCurrentGeneration.getFitness()).thenReturn(fitnessOfGenomeFromCurrentGeneration);
when(genomeFromCurrentGeneration.getBirthGeneration()).thenReturn(genePool.getCurrentGeneration());
genePool.reportDeadGenome(genomeFromCurrentGeneration);
assert genePool.getFitnessSum() == oldFitnessSum - fitnessOfGenomeFromCurrentGeneration : "If a genome has been reported dead the overall fitness sum should decrease by its fitness";
assert genePool.getNumberOfDeadChildren() == 1;