Example #1
0
        public void DealDamages_ShouldSumAllDamage_WhenMultipleDamages()
        {
            // Arrange
            var instance = new HitPoints(42);
            var damages  = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 1
                },
                new DealDamage {
                    DamageType = DamageTypes.Cold, Hp = 2
                },
                new DealDamage {
                    DamageType = DamageTypes.Necrotic, Hp = 3
                },
                new DealDamage {
                    DamageType = DamageTypes.Psychic, Hp = 4
                },
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(32);
        }
Example #2
0
        public void DealDamages_ShouldSubtractHp()
        {
            // Arrange
            var instance = new HitPoints(42);
            var damages  = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 5
                },
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(37);
        }
Example #3
0
        public void DealDamages_ShouldChangeStatusToDead_WhenRemainingDamageIsMaxOrMore()
        {
            // Arrange
            var instance = new HitPoints(42);
            var damages  = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 84
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(0);
            instance.DeathSavingThrowFailures.Should().Be(0);
            instance.Status.Should().Be(LifeStatuses.Dead);
        }
Example #4
0
        public void DealDamages_ShouldNotHaveNegativeHP_WhenDamageIsMoreThanCurrent()
        {
            // Arrange
            var instance = new HitPoints(42);
            var damages  = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 45
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(0);
            instance.DeathSavingThrowFailures.Should().Be(0);
            instance.Status.Should().Be(LifeStatuses.Dying);
        }
Example #5
0
        public void DealDamages_ShouldChangeStatusToDying_WhenStableAndDamageIsSameAsCurrent()
        {
            // Arrange
            var instance = new HitPoints(42);
            var damages  = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 42
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(0);
            instance.DeathSavingThrowFailures.Should().Be(0);
            instance.Status.Should().Be(LifeStatuses.Dying);
        }
Example #6
0
        public void DealDamages_ShouldDoDoubleDamage_WhenVulnerability()
        {
            // Arrange
            var instance = new HitPoints(42);

            instance.AddVulnerability(DamageTypes.Fire);
            var damages = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 5
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(32);
        }
Example #7
0
        public void DealDamages_ShouldDoHalfDamageRoundedDown_WhenResitance()
        {
            // Arrange
            var instance = new HitPoints(42);

            instance.AddResistance(DamageTypes.Fire);
            var damages = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 5
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(40);
        }
Example #8
0
        public void DealDamages_ShouldUseTemporaryHPThenCurrentHP_WhenNotEnough()
        {
            // Arrange
            var instance = new HitPoints(42);

            instance.AddTemporaryHp(5);
            var damages = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 10
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(37);
            instance.TemporaryHp.Should().Be(0);
        }
Example #9
0
        public void DealDamages_ShouldProcessResistanceThenVulnerability_WhenBoth()
        {
            // Arrange
            var instance = new HitPoints(42);

            instance.AddResistance(DamageTypes.Fire);
            instance.AddVulnerability(DamageTypes.Fire);
            var damages = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 9
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(34);
        }
Example #10
0
        public void DealDamages_ShouldIncrememntFailures_WhenDying()
        {
            // Arrange
            var instance = new HitPoints(42);

            instance.CurrentHp = 0;
            instance.Status    = LifeStatuses.Dying;
            var damages = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 5
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(0);
            instance.DeathSavingThrowFailures.Should().Be(1);
        }
Example #11
0
        public void DealDamages_ShouldOnlyDoHalfDamage_WhenMultipleResistances()
        {
            // Arrange
            var instance = new HitPoints(42);

            instance.AddResistance(DamageTypes.Fire);
            instance.AddResistance(DamageTypes.Fire);
            instance.AddResistance(DamageTypes.Fire);
            var damages = new DealDamage[]
            {
                new DealDamage {
                    DamageType = DamageTypes.Fire, Hp = 8
                }
            };

            // Act
            instance.DealDamages(damages);
            // Assert
            instance.CurrentHp.Should().Be(38);
        }