public void ApplyTo_NullICharacter_Throws() { // Arrange var shield = new LionsShield(); // Act TestDelegate applyTo = () => shield.ApplyTo(null); // Assert Assert.Throws <ArgumentNullException>(applyTo); }
public void ApplyTo_ArmorBonusAndArmorCheckPenalty() { // Arrange 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.ArmorClass.ShieldBonuses) .Returns(shieldBonusTracker); mockCharacter.Setup(c => c.Skills.GetAllSkills()) .Returns(new ISkill[] { mockUnaffectedSkill.Object, mockAffectedSkill.Object }); var shield = new LionsShield(); // Act shield.ApplyTo(mockCharacter.Object); // Assert Mock.Get(shieldBonusTracker) .Verify(bt => bt.Add(It.Is <Func <byte> >(calc => 4 == calc())), "Lion's Shield should add a +4 shield bonus to a character's armor class."); Mock.Get(unaffectedPenalty) .Verify(bt => bt.Add(It.Is <Func <byte> >(calc => 0 == calc())), "Lion's 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())), "Lion's Shield should add a -1 penalty to skills where armor check penalties apply."); }