public void GetTotal_Aggregates() { // Arrange var mockBaseAttackBonus = new Mock <IBaseAttackBonus>(); mockBaseAttackBonus.Setup(bab => bab.GetTotal()) .Returns(20); var mockAttackBonusesSection = new Mock <IAttackBonusSection>(); mockAttackBonusesSection.Setup(abs => abs.BaseAttackBonus) .Returns(mockBaseAttackBonus.Object); var mockStrength = new Mock <IAbilityScore>(); mockStrength.Setup(str => str.GetModifier()) .Returns(3); var mockDexterity = new Mock <IAbilityScore>(); mockDexterity.Setup(dex => dex.GetModifier()) .Returns(2); var mockAbilityScores = new Mock <IAbilityScoreSection>(); mockAbilityScores.Setup(abs => abs.Strength) .Returns(mockStrength.Object); mockAbilityScores.Setup(abs => abs.Dexterity) .Returns(mockDexterity.Object); var mockCharacter = new Mock <ICharacter>(); mockCharacter.Setup(c => c.AttackBonuses) .Returns(mockAttackBonusesSection.Object); mockCharacter.Setup(c => c.AbilityScores) .Returns(mockAbilityScores.Object); mockCharacter.Setup(c => c.Size) .Returns(SizeCategory.Large); CombatManeuverDefense cmd = new CombatManeuverDefense(mockCharacter.Object); cmd.CircumstanceBonuses.Add(() => 2); cmd.DeflectionBonuses.Add(() => 2); cmd.DodgeBonuses.Add(() => 2); cmd.InsightBonuses.Add(() => 2); cmd.LuckBonuses.Add(() => 2); cmd.MoraleBonuses.Add(() => 2); cmd.ProfaneBonuses.Add(() => 2); cmd.SacredBonuses.Add(() => 2); cmd.UntypedBonuses.Add(() => 2); cmd.Penalties.Add(() => 10); // Act var result = cmd.GetTotal(); // Assert Assert.AreEqual(44, result, "44 = 10 + (20 BAB) + (1 large) + (2 dex) + (3 str) + (2 circumstance) + (2 deflection) + (2 dodge) + (2 insight) + (2 luck) + (2 morale) + (2 profane) + (2 sacred) + (2 untyped) - (10 penalties)"); }
public void GetTotal_Default() { // Arrange var mockBaseAttackBonus = new Mock <IBaseAttackBonus>(); mockBaseAttackBonus.Setup(bab => bab.GetTotal()) .Returns(0); var mockAttackBonusesSection = new Mock <IAttackBonusSection>(); mockAttackBonusesSection.Setup(abs => abs.BaseAttackBonus) .Returns(mockBaseAttackBonus.Object); var mockStrength = new Mock <IAbilityScore>(); mockStrength.Setup(str => str.GetModifier()) .Returns(0); var mockDexterity = new Mock <IAbilityScore>(); mockDexterity.Setup(dex => dex.GetModifier()) .Returns(0); var mockAbilityScores = new Mock <IAbilityScoreSection>(); mockAbilityScores.Setup(abs => abs.Strength) .Returns(mockStrength.Object); mockAbilityScores.Setup(abs => abs.Dexterity) .Returns(mockDexterity.Object); var mockCharacter = new Mock <ICharacter>(); mockCharacter.Setup(c => c.AttackBonuses) .Returns(mockAttackBonusesSection.Object); mockCharacter.Setup(c => c.AbilityScores) .Returns(mockAbilityScores.Object); mockCharacter.Setup(c => c.Size) .Returns(SizeCategory.Medium); CombatManeuverDefense cmd = new CombatManeuverDefense(mockCharacter.Object); // Act var result = cmd.GetTotal(); // Assert Assert.AreEqual(10, result, "A medium-sized character with +0 BAB, 10 strength, and 10 dexterity should have a CMD of 10."); }