public void Constructor_NullIAttackBonus_Throws()
        {
            // Arrange
            var character    = Mock.Of <ICharacter>();
            var abilityScore = Mock.Of <IAbilityScore>();
            IUniversalAttackBonus attackBonus = null;

            // Act
            TestDelegate constructor = () => new WeaponAttackBonus(character, abilityScore, attackBonus);

            // Assert
            Assert.Throws <ArgumentNullException>(constructor);
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Core.Domain.Characters.AttackBonuses.SpecificAttackBonus"/> class.
 /// </summary>
 /// <param name="character">The character to whom this attack bonus belongs.</param>
 /// <param name="keyAbilityScore">The ability score associated with this attack bonus.</param>
 /// <param name="sharedAttackBonus">The generic attack bonus which contains universal bonuses which apply to this attack bonus.</param>
 /// <exception cref="System.ArgumentNullException">Thrown when an argument is null.</exception>
 internal WeaponAttackBonus(ICharacter character, IAbilityScore keyAbilityScore, IUniversalAttackBonus sharedAttackBonus)
     : base()
 {
     this.Character         = character ?? throw new ArgumentNullException(nameof(character), "Argument cannot be null.");
     this.KeyAbilityScore   = keyAbilityScore ?? throw new ArgumentNullException(nameof(keyAbilityScore), "Argument cannot be null");
     this.SharedAttackBonus = sharedAttackBonus ?? throw new ArgumentNullException(nameof(sharedAttackBonus), "Argument cannot be null");
     this.EnhancementBonuses.Add(
         () => this.SharedAttackBonus.EnhancementBonuses?.GetTotal() ?? 0
         );
     this.UntypedBonuses.Add(
         () => this.SharedAttackBonus.UntypedBonuses?.GetTotal() ?? 0
         );
     this.Penalties.Add(
         () => this.SharedAttackBonus.Penalties?.GetTotal() ?? 0
         );
 }