public void ApplyTo_ArmorBonusAndArmorCheckPenalty() { // Arrange var slaKnown = Mock.Of <ISpellLikeAbilityCollection>(); var unaffectedPenalty = Mock.Of <IModifierTracker>(); var mockUnaffectedSkill = new Mock <ISkill>(); mockUnaffectedSkill.Setup(s => s.ArmorCheckPenaltyApplies) .Returns(false); mockUnaffectedSkill.Setup(s => s.Penalties) .Returns(unaffectedPenalty); var affectedPenalty = Mock.Of <IModifierTracker>(); var mockAffectedSkill = new Mock <ISkill>(); mockAffectedSkill.Setup(s => s.ArmorCheckPenaltyApplies) .Returns(true); mockAffectedSkill.Setup(s => s.Penalties) .Returns(affectedPenalty); var shieldBonusTracker = Mock.Of <IModifierTracker>(); var mockCharacter = new Mock <ICharacter>(); mockCharacter.Setup(c => c.SpellLikeAbilities.Known) .Returns(slaKnown); mockCharacter.Setup(c => c.ArmorClass.ShieldBonuses) .Returns(shieldBonusTracker); mockCharacter.Setup(c => c.Skills.GetAllSkills()) .Returns(new ISkill[] { mockUnaffectedSkill.Object, mockAffectedSkill.Object }); var shield = new WingedShield(); // Act shield.ApplyTo(mockCharacter.Object); // Assert Mock.Get(shieldBonusTracker) .Verify(bt => bt.Add(It.Is <Func <byte> >(calc => 5 == calc())), "Winged Shield should add a +5 shield bonus to a character's armor class."); Mock.Get(unaffectedPenalty) .Verify(bt => bt.Add(It.Is <Func <byte> >(calc => 0 == calc())), "Winged Shield should not add penalties to skills where armor check penalties do not apply."); Mock.Get(affectedPenalty) .Verify(bt => bt.Add(It.Is <Func <byte> >(calc => 1 == calc())), "Winged Shield should add a -1 penalty to skills where armor check penalties apply."); Mock.Get(slaKnown) .Verify(r => r.Add(It.Is <ISpellLikeAbility>(sla => sla.Spell is Core.Domain.Spells.Paizo.CoreRulebook.Fly && 1 == sla.UsesPerDay && 5 == sla.CasterLevel.GetTotal() && 3 == sla.Spell.Level)), "Winged Shield should let character use Fly (level 3) once per day as a spell-like ability at caster level 5."); }
public void ApplyTo_NullICharacter_Throws() { // Arrange var shield = new WingedShield(); // Act TestDelegate applyTo = () => shield.ApplyTo(null); // Assert Assert.Throws <ArgumentNullException>(applyTo); }