示例#1
0
        private ZooAnimal GetDeadAnimal()
        {
            var now            = DateTime.UtcNow;
            var nowPlusOneHour = now.AddHours(1);

            var mockZoo = new Mock <IZoo>();

            mockZoo.SetupSequence(x => x.TimeOfDay)
            .Returns(now)
            .Returns(now)
            .Returns(nowPlusOneHour);

            mockZoo.Setup(x => x.TimeIncrements).Returns(360);
            var zooAnimal = new ZooAnimal(_zooAnimalType, mockZoo.Object);

            //kill the animal
            zooAnimal.DecreaseHealth(71);
            mockZoo.Raise(x => x.StatusChanged += null, this, new EventArgs());
            return(zooAnimal);
        }
示例#2
0
        public void WhenDecreaseIsCalled_ThenHealthIsDecreasedByTheGivenPercentage()
        {
            double previousHealth = _generalZooAnimal.Health;

            _generalZooAnimal.DecreaseHealth(10);

            Assert.AreEqual(90.00, _generalZooAnimal.Health);
        }