Exemplo n.º 1
0
        public void WhenABeeIsFirstCreated_ItIsNotDead()
        {
            // Arrange
            var bee = new TestBee(100, 50);

            // Assert
            Assert.IsFalse(bee.IsDead);
        }
Exemplo n.º 2
0
        public void WhenCallingToStringOnABeeAndTheBeeIsAlive_TheStringContainsAlive()
        {
            // Arrange
            var bee = new TestBee(50, 50);

            // Act
            var beeString = bee.ToString();

            // Assert
            Assert.IsTrue(beeString.Contains("alive"));
        }
Exemplo n.º 3
0
        public void WhenCallingToStringOnABee_TheStringContainsItsHealth()
        {
            // Arrange
            var bee = new TestBee(50, 50);

            // Act
            var beeString = bee.ToString();

            // Assert
            Assert.IsTrue(beeString.Contains(bee.Health.ToString()));
        }
Exemplo n.º 4
0
        public void WhenABeeIsDamagedMoreThanOneHundredPercent_ItsHealthIsZero()
        {
            // Arrange
            var bee = new TestBee(50, 50);

            // Act
            bee.Damage(200);

            // Assert
            Assert.AreEqual(0, bee.Health);
        }
Exemplo n.º 5
0
        public void WhenABeeIsDamagedSlightlyLessThanItsThreshold_ItLives()
        {
            // Arrange
            var threshold = 50;
            var bee       = new TestBee(50, threshold);

            // Act
            bee.Damage(threshold - 1);

            // Assert
            Assert.IsFalse(bee.IsDead);
        }
Exemplo n.º 6
0
        public void WhenCallingToStringOnABee_TheStringContainsItsType()
        {
            // Arrange
            var bee = new TestBee(50, 50);

            // Act
            bee.Damage(100);
            var beeString = bee.ToString();

            // Assert
            Assert.IsTrue(beeString.Contains("TestBee"));
        }
Exemplo n.º 7
0
        public void WhenCallingToStringOnABeeAndTheBeeIsDead_TheStringContainsDead()
        {
            // Arrange
            var bee = new TestBee(50, 50);

            // Act
            bee.Damage(100);
            var beeString = bee.ToString();

            // Assert
            Assert.IsTrue(beeString.Contains("dead"));
        }
Exemplo n.º 8
0
        public void WhenABeeIsDamagedLessThanZeroPercent_ItsHealthIsUnchanged()
        {
            // Arrange
            var initialHealth = 50;
            var bee           = new TestBee(initialHealth, 50);

            // Act
            bee.Damage(-100);

            // Assert
            Assert.AreEqual(initialHealth, bee.Health);
        }
Exemplo n.º 9
0
        public void WhenABeeIsDamagedSlightlyMoreThanItsThreshold_ItDies()
        {
            // Arrange
            var threshold = 50;
            var bee       = new TestBee(50, threshold);

            // Act
            bee.Damage(threshold + 1);

            // Assert
            Assert.IsTrue(bee.IsDead);
        }
Exemplo n.º 10
0
        public void WhenABeeIsDamagedByFiftyOnePercent_ItsHealthIsReducedToFourtyNinePercent()
        {
            // Arrange
            var initialHealth = 50f;
            var fourtyNinePercentOfInitialHealth = initialHealth * 0.49;
            var bee = new TestBee(initialHealth, 50);

            // Act
            bee.Damage(51);

            // Assert
            Assert.AreEqual(fourtyNinePercentOfInitialHealth, bee.Health);
        }
Exemplo n.º 11
0
        public void WhenDamagingABeeTwiceForFiftyPercent_ItsHealthIsReducedToTwentyFivePercent()
        {
            // Arrange
            var initialHealth = 50f;
            var twentyFivePercentOfInitialHealth = initialHealth * 0.25;
            var bee = new TestBee(initialHealth, 10);

            // Act
            bee.Damage(50);
            bee.Damage(50);

            // Assert
            Assert.AreEqual(twentyFivePercentOfInitialHealth, bee.Health);
        }
Exemplo n.º 12
0
        public void WhenDamagingADeadBee_NoFurtherHeathDeductionsAreMadeAndNoErrorIsThrown()
        {
            // Arrange
            var initialHealth = 50f;
            var bee           = new TestBee(initialHealth, 99);

            // Act
            bee.Damage(50);
            var healthAfterFirstDamage = bee.Health;

            bee.Damage(50);
            var healthAfterSecondDamage = bee.Health;

            // Assert
            Assert.AreEqual(healthAfterFirstDamage, healthAfterSecondDamage);
        }