Exemplo n.º 1
0
        public List <IAnimal> Behave(IAnimal animal, IEnumerable <IAnimal> animals)
        {
            animals = TryDie(animal, animals);

            animals = TryGiveBirth(animal, animals);

            if (animal.IsPredator)
            {
                animal.Coordinates = TryChasePrey(animal, animals);
                animal.Health      = _healthLogic.DecreaseHealth(animal.Health);
                animals            = TryEatPrey(animal, animals);
            }

            else
            {
                animal.Coordinates = TryEscape(animal, animals);
                animal.Health      = _healthLogic.DecreaseHealth(animal.Health);
            }

            return(animals.ToList());
        }
Exemplo n.º 2
0
        public void DecreaseHealth_When_PositiveHealth_Expect_LessHealth()
        {
            //Arrange
            decimal value = 5m;

            //Act
            var result = _classUnderTest.DecreaseHealth(value);

            //Assert
            Assert.Greater(value, result);
            Assert.AreEqual(result, 4.5);
            Assert.AreEqual(result.GetType(), typeof(decimal));
        }