public void HerbivoreSurvivesTest() { var rng = new Random(); List <bool> results = new List <bool>(); for (int i = 0; i < 10000; i++) { var testHerbivore = new Herbivore(rng) { Age = 5, Weight = 100 }; // Herbivore with high fitness testHerbivore.Params.Omega = 1; testHerbivore.Death(); results.Add(testHerbivore.IsAlive); } var dead = results.Where(i => !i).Count() / (double)results.Count() * 100.0; Assert.True(dead < 1); // Less than 1% of all individuals die }
public void HerbivoreDiesTest() { /*Check to confirm death when fitness is low*/ var rng = new Random(); List <bool> results = new List <bool>(); for (int i = 0; i < 10000; i++) { var testHerbivore = new Herbivore(rng) { Age = 60, Weight = 1 }; // Herbivore with low fitness testHerbivore.Params.Omega = 1; // Omega = 1 removes the preset amount of survivals testHerbivore.Death(); results.Add(testHerbivore.IsAlive); } var dead = results.Where(i => !i).Count() / (double)results.Count() * 100.0; Assert.True(dead > 99); // More than 99% of all individuals die }