Esempio n. 1
0
        public void HerbivoreParmeterInheretanceTest()
        {
            /*Assert that the offspring of a herbivore inherits a
             * parameter object with type HerbivoreParams and has the same values as the mother
             * while also not being the same actual object (reference/pointer) */
            var rng      = new Random();
            var testHerb = new Herbivore(rng)
            {
                Weight = 50, Age = 5
            };                                                          // High Fitness
            var defaultParams = testHerb.Params;

            testHerb.Params.Gamma = 10;
            var offspring = testHerb.Birth(20);

            Assert.NotEqual(offspring.Params, defaultParams);
        }
Esempio n. 2
0
        [Fact] //fct shortcut
        public void HerbivoreGiveBirthTest()
        {
            /*Set Weight and param gamme sufficiently high such that birth will succeed
             * Check if Given birth is set to true
             * Check that the offspring is of the right type
             * Assert that the weight of mother reduces after birth
             */
            var testHerb = new Herbivore(new Random())
            {
                Weight = 150
            };

            Assert.False(testHerb.GivenBirth);
            testHerb.Params.Gamma = 10;
            var result = testHerb.Birth(10);

            Assert.NotNull(result);
            Assert.True(result.GetType().Name == "Herbivore");
            Assert.True(testHerb.GivenBirth);
            Assert.True(testHerb.Weight < 150);
            Assert.True(result != testHerb);
        }