Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }