public void GenerateCustomMundaneArmor()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomArmorTemplate(name);

            var attributes = new[] { "attribute 1", "attribute 2" };
            var tableName  = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Armor);

            mockCollectionsSelector.Setup(p => p.SelectFrom(tableName, name)).Returns(attributes);

            mockPercentileSelector.Setup(p => p.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes)).Returns("size");
            mockPercentileSelector.Setup(p => p.SelectFrom <bool>(TableNameConstants.Percentiles.Set.IsMasterwork)).Returns(true);

            var baseNames = new[] { "base name", "other base name" };

            mockCollectionsSelector.Setup(s => s.SelectFrom(TableNameConstants.Collections.Set.ItemGroups, name)).Returns(baseNames);

            armorSelection.ArmorBonus        = 9266;
            armorSelection.ArmorCheckPenalty = -90210;
            armorSelection.MaxDexterityBonus = 42;
            mockArmorDataSelector.Setup(s => s.Select(name)).Returns(armorSelection);

            var item  = mundaneArmorGenerator.Generate(template);
            var armor = item as Armor;

            itemVerifier.AssertMundaneItemFromTemplate(armor, template);
            Assert.That(armor.ItemType, Is.EqualTo(ItemTypeConstants.Armor));
            Assert.That(armor.Attributes, Is.EquivalentTo(attributes));
            Assert.That(armor.Traits, Is.All.Not.EqualTo("size"));
            Assert.That(armor.Size, Is.EqualTo("size"));
            Assert.That(armor.Traits, Is.All.Not.EqualTo(TraitConstants.Masterwork));
            Assert.That(armor.Quantity, Is.EqualTo(1));
            Assert.That(armor.BaseNames, Is.EqualTo(baseNames));
            Assert.That(armor.ArmorBonus, Is.EqualTo(9266));
            Assert.That(armor.ArmorCheckPenalty, Is.EqualTo(-90210));
            Assert.That(armor.MaxDexterityBonus, Is.EqualTo(42));
        }
Ejemplo n.º 2
0
        public void GenerateArmorOfSize_FromTemplate(string itemName, string size)
        {
            var template = itemVerifier.CreateRandomArmorTemplate(itemName);

            template.Traits.Add(size);

            var item = armorGenerator.Generate(template);

            itemVerifier.AssertItem(item);
            Assert.That(item, Is.InstanceOf <Armor>());

            var armor = item as Armor;

            Assert.That(armor.Size, Is.EqualTo(size), armor.Name);
            Assert.That(armor.Traits, Does.Not.Contain(size)
                        .And.SupersetOf(template.Traits.Take(2)), armor.Name);
        }
        public void GenerateSpecificCustomArmor()
        {
            var name                = Guid.NewGuid().ToString();
            var template            = itemVerifier.CreateRandomTemplate(name);
            var specialAbilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);

            var tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Armor);

            mockCollectionsSelector.Setup(p => p.SelectFrom(tableName, name)).Throws <ArgumentException>();

            var abilities = new[]
            {
                new SpecialAbility {
                    Name = specialAbilityNames.First()
                },
                new SpecialAbility {
                    Name = specialAbilityNames.Last()
                }
            };

            mockSpecialAbilitiesGenerator.Setup(p => p.GenerateFor(template.Magic.SpecialAbilities)).Returns(abilities);

            var specificArmor = itemVerifier.CreateRandomArmorTemplate(name);

            specificArmor.ItemType = ItemTypeConstants.Armor;
            mockSpecificGearGenerator.Setup(g => g.GenerateFrom(It.Is <Item>(i => i.NameMatches(name)))).Returns(specificArmor);
            mockSpecificGearGenerator.Setup(g => g.IsSpecific(It.Is <Item>(i => i.NameMatches(name)))).Returns(true);

            var armor = magicalArmorGenerator.Generate(template, true);

            Assert.That(armor.Quantity, Is.EqualTo(1));
            Assert.That(armor.Name, Is.EqualTo(specificArmor.Name));
            Assert.That(armor.BaseNames, Is.EquivalentTo(specificArmor.BaseNames));
            Assert.That(armor.ItemType, Is.EqualTo(ItemTypeConstants.Armor));
            Assert.That(armor.Magic.SpecialAbilities, Is.EquivalentTo(specificArmor.Magic.SpecialAbilities));
        }