public void GetSchools_EnhancementBonusAndOneMore() { IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1; IEnchantment enchantment = new EnhancementBonus(1); var mockEnchantment = new Mock <IEnchantment>(); mockEnchantment.Setup(e => e.GetSchools()) .Returns(new School[] { School.Necromancy }); var necroEnch = mockEnchantment.Object; var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); aggregator.EnchantWith(necroEnch); var schools = aggregator.GetSchools(); // Assert Assert.That(schools, Is.EquivalentTo(necroEnch.GetSchools()), "If there is at least one non-enhancement bonus enchantment, the enhancement bonus's schools should be ignored."); }
public void PlusThree_Defaults() { // Arrange byte bonus = 3; // Act IShieldEnchantment enchantment = new EnhancementBonus(bonus); // Assert Assert.AreEqual(3, enchantment.SpecialAbilityBonus); Assert.AreEqual(9, enchantment.CasterLevel); Assert.AreEqual(0, enchantment.Cost); Assert.That(enchantment.GetSchools(), Has.Exactly(1).Matches <School>(s => School.Abjuration == s)); Assert.AreEqual("+3", enchantment.Name.Text); }
public void Shield_PlusFive_Enchant() { // Arrange var armorEnhancementBonus = Mock.Of <IModifierTracker>(); var mockShieldBonusAgg = new Mock <IArmorClassAggregator>(); mockShieldBonusAgg.Setup(agg => agg.EnhancementBonuses) .Returns(armorEnhancementBonus); IArmorClassAggregator shieldBonus = mockShieldBonusAgg.Object; var hardnessEnhancementBonus = Mock.Of <IModifierTracker>(); var mockHardnessAgg = new Mock <IHardnessAggregator>(); mockHardnessAgg.Setup(agg => agg.EnhancementBonuses) .Returns(hardnessEnhancementBonus); IHardnessAggregator hardness = mockHardnessAgg.Object; var hitPointsEnhancementBonus = Mock.Of <IModifierTracker>(); var mockHitPointAgg = new Mock <IHitPointsAggregator>(); mockHitPointAgg.Setup(agg => agg.EnhancementBonuses) .Returns(hitPointsEnhancementBonus); IHitPointsAggregator hitPoints = mockHitPointAgg.Object; IEnchantmentAggregator <IShieldEnchantment, Shield> enchantments = null; var shield = new Mock <Shield>(MockBehavior.Loose, shieldBonus, hardness, hitPoints, enchantments) { CallBase = true }.Object; IShieldEnchantment enchantment = new EnhancementBonus(5); // Act enchantment.Enchant(shield); // Assert Mock.Get(armorEnhancementBonus) .Verify(ac => ac.Add(It.Is <Func <byte> >(calc => 5 == calc())), "A +5 bonus was not applied to the shield's armor class bonus correctly."); Mock.Get(hardnessEnhancementBonus) .Verify(bhn => bhn.Add(It.Is <Func <byte> >(calc => 10 == calc())), "A +10 bonus was not applied to the shield's hardness correctly."); Mock.Get(hitPointsEnhancementBonus) .Verify(hp => hp.Add(It.Is <Func <byte> >(calc => 50 == calc())), "A +50 bonus was not applied to the shield's hit points correctly."); }
public void Armor_PlusOne_Enchant() { // Arrange var armorEnhancementBonus = Mock.Of <IModifierTracker>(); var mockArmorBonusAgg = new Mock <IArmorClassAggregator>(); mockArmorBonusAgg.Setup(agg => agg.EnhancementBonuses) .Returns(armorEnhancementBonus); IArmorClassAggregator armorBonus = mockArmorBonusAgg.Object; var hardnessEnhancementBonus = Mock.Of <IModifierTracker>(); var mockHardnessAgg = new Mock <IHardnessAggregator>(); mockHardnessAgg.Setup(agg => agg.EnhancementBonuses) .Returns(hardnessEnhancementBonus); IHardnessAggregator hardness = mockHardnessAgg.Object; var hitPointsEnhancementBonus = Mock.Of <IModifierTracker>(); var mockHitPointAgg = new Mock <IHitPointsAggregator>(); mockHitPointAgg.Setup(agg => agg.EnhancementBonuses) .Returns(hitPointsEnhancementBonus); IHitPointsAggregator hitPoints = mockHitPointAgg.Object; var armor = new Mock <Core.Domain.Items.Armor.Armor>(MockBehavior.Loose, armorBonus, hardness, hitPoints, null) { CallBase = true }.Object; IArmorEnchantment enchantment = new EnhancementBonus(1); // Act enchantment.Enchant(armor); // Assert Mock.Get(armorEnhancementBonus) .Verify(ac => ac.Add(It.Is <Func <byte> >(calc => 1 == calc())), "A +1 bonus was not applied to the armor's armor class bonus correctly."); Mock.Get(hardnessEnhancementBonus) .Verify(bhn => bhn.Add(It.Is <Func <byte> >(calc => 2 == calc())), "A +2 bonus was not applied to the armor's hardness correctly."); Mock.Get(hitPointsEnhancementBonus) .Verify(hp => hp.Add(It.Is <Func <byte> >(calc => 10 == calc())), "A +10 bonus was not applied to the armor's hit points correctly."); }
public void GetMarketPrice_OnlySpecialAbilityBonuses() { IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1000; IEnchantment enchantment = new EnhancementBonus(5); var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); var price = aggregator.GetMarketPrice(); // Assert Assert.AreEqual(25000, price, "25000 = 5^2 * 1000"); }
public void GetSchools_OnlyEnhancementBonus() { IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1; IEnchantment enchantment = new EnhancementBonus(1); var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); var schools = aggregator.GetSchools(); // Assert Assert.That(schools, Is.EquivalentTo(enchantment.GetSchools()), "If the only enchantment is an enhancement bonus, the enhancement bonus's schools should be returned."); }
public void EnchantWith__RoundTrip() { // Arrange IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1; IEnchantment enchantment = new EnhancementBonus(1); var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); var enchantments = aggregator.GetEnchantments(); // Assert Assert.That(enchantments, Is.EquivalentTo(new IEnchantment[] { enchantment }), "Enchantments put into the EnchantmentAggregator should make a round trip."); }
public void EnchantWith_CallsAction() { // Arrange IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1; IEnchantment enchantment = new EnhancementBonus(1); var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); // Assert Mock.Get(action).Verify(a => a(It.Is <IEnchantment>(ench => ench == enchantment), It.Is <IItem>(i => i == item)), "EnchantmentAggregator.EnchantWith() should call the Action delegate and feed it the item to be enchanted and the enchantment."); }
public void GetCasterLevel_ReturnsMax() { IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1; IEnchantment enchantment = new EnhancementBonus(5); // caster level 15 var mockEnchantment = new Mock <IEnchantment>(); mockEnchantment.Setup(e => e.CasterLevel) .Returns(10); var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); aggregator.EnchantWith(mockEnchantment.Object); var casterLevel = aggregator.GetCasterLevel(); // Assert Assert.AreEqual(15, casterLevel); }
public string Weapon_FullName() { string temp = string.Empty; if (EnhancementBonus != 0) { if (EnhancementBonus > 0) { temp += "+" + EnhancementBonus.ToString() + PathfinderConstants.SPACE; } else { temp += EnhancementBonus.ToString() + PathfinderConstants.SPACE; } } else if (Masterwork) { temp += "mwk "; } temp += WeaponSpecialAbilities.ToString(); temp += PathfinderConstants.SPACE + search_name.ToLower(); return(temp); }
public void GetNames() { IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1000; IEnchantment enchantment = new EnhancementBonus(5); var mockEnchantment = new Mock <IEnchantment>(); mockEnchantment.Setup(e => e.Name) .Returns(new NameFragment("Other Enchantment", "http://example.com")); var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); aggregator.EnchantWith(mockEnchantment.Object); var(enhName, otherNames) = aggregator.GetNames(); // Assert Assert.AreEqual(enchantment.Name, enhName); Assert.That(otherNames, Is.EquivalentTo(new INameFragment[] { new NameFragment("Other Enchantment", "http://example.com") })); }
public void GetMarketPrice_MixedCosts() { IItem item = Mock.Of <IItem>(); Action <IEnchantment, IItem> action = Mock.Of <Action <IEnchantment, IItem> >(); double costCoefficient = 1000; IEnchantment enchantment = new EnhancementBonus(5); var mockEnchantment = new Mock <IEnchantment>(); mockEnchantment.Setup(e => e.Cost) .Returns(1000); var aggregator = new Mock <EnchantmentAggregator <IEnchantment, IItem> >(MockBehavior.Loose, item, action, costCoefficient) { CallBase = true }.Object; // Act aggregator.EnchantWith(enchantment); aggregator.EnchantWith(mockEnchantment.Object); var price = aggregator.GetMarketPrice(); // Assert Assert.AreEqual(26000, price, "26000 = (5^2 * 1000) + (1000 flat costs)"); }