Example #1
0
 public ReadOnlyAbility(Ability ability)
 {
     if (ability == null) {
         throw new ArgumentNullException("ability", "ReadOnlyAbility requires a normal ability");
     }
     _ability = ability;
 }
Example #2
0
        public void ImplicitOperator_AssignToInt_ReturnsScore()
        {
            // Assign
            // Act
            int score = new Ability(AbilityType.Strength, 10);

            // Assert
            Assert.Equal(10, score);
        }
Example #3
0
        public void Increase_With2_IncreasesScoreWith2()
        {
            // Assign
            var attr = new Ability(AbilityType.Strength, 10);

            // Act
            attr.Increase(2);

            // Assert
            Assert.Equal(12, attr.Score);
        }
Example #4
0
        public void Decrease_With2_DecreasesBaseScoreWith2()
        {
            // Assign
            var attr = new Ability(AbilityType.Strength, 10);

            // Act
            attr.Decrease(2);

            // Assert
            Assert.Equal(8, attr.BaseScore);
        }
Example #5
0
        public void Increase_With2_IncreasesModifierWith1()
        {
            // Assign
            var attr = new Ability(AbilityType.Strength, 10);
            var before = attr.Modifier;

            // Act
            attr.Increase(2);

            // Assert
            Assert.Equal(before + 1, attr.Modifier);
        }
Example #6
0
        public void Modifier_WithScore0_ThrowsException()
        {
            // Assign
            var attr = new Ability(AbilityType.Strength, 0);

            // Act
            // Assert
            Assert.Throws<ArgumentException>(() => attr.Modifier);
        }
Example #7
0
        public void Modifier_GivenScore_ReturnsCorrectValue(int score, int expectedModifier)
        {
            // Assign
            // Act
            var attr = new Ability(AbilityType.Strength, score);

            // Assert
            Assert.Equal(expectedModifier, attr.Modifier);
        }