Exemplo n.º 1
0
        public void GenerateCustomArmor()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

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

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

            var specialAbilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);
            var abilities           = new[]
            {
                new SpecialAbility {
                    Name = specialAbilityNames.First()
                },
                new SpecialAbility {
                    Name = specialAbilityNames.Last()
                }
            };

            mockSpecialAbilitiesGenerator.Setup(p => p.GenerateFor(specialAbilityNames)).Returns(abilities);

            var armor = magicalArmorGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(armor, template);
            Assert.That(armor.Quantity, Is.EqualTo(1));
            Assert.That(armor.ItemType, Is.EqualTo(ItemTypeConstants.Armor));
            Assert.That(armor.Attributes, Is.EquivalentTo(attributes));
            Assert.That(armor.Magic.SpecialAbilities, Is.EquivalentTo(abilities));
        }
        public void GenerateCustomStaff()
        {
            var name                = Guid.NewGuid().ToString();
            var template            = itemVerifier.CreateRandomTemplate(name);
            var specialAbilityNames = template.Magic.SpecialAbilities.Select(a => a.Name);

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

            mockSpecialAbilitiesGenerator.Setup(p => p.GenerateFor(specialAbilityNames)).Returns(abilities);

            var staff = staffGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(staff, template);
            Assert.That(staff.ItemType, Is.EqualTo(ItemTypeConstants.Staff));
            Assert.That(staff.Attributes, Contains.Item(AttributeConstants.Charged));
            Assert.That(staff.Attributes, Contains.Item(AttributeConstants.OneTimeUse));
            Assert.That(staff.Attributes.Count(), Is.EqualTo(2));
            Assert.That(staff.Quantity, Is.EqualTo(1));
        }
Exemplo n.º 3
0
        public void GenerateCustomPotion()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var potion = potionGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(potion, template);
            Assert.That(potion.BaseNames.Single(), Is.EqualTo(name));
            Assert.That(potion.Attributes, Contains.Item(AttributeConstants.OneTimeUse));
            Assert.That(potion.IsMagical, Is.True);
            Assert.That(potion.ItemType, Is.EqualTo(ItemTypeConstants.Potion));
            Assert.That(potion.Quantity, Is.EqualTo(1));
        }
Exemplo n.º 4
0
        public void GenerateCustomScroll()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var scroll = scrollGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(scroll, template);
            Assert.That(scroll.ItemType, Is.EqualTo(ItemTypeConstants.Scroll));
            Assert.That(scroll.IsMagical, Is.True);
            Assert.That(scroll.Attributes.Single(), Is.EqualTo(AttributeConstants.OneTimeUse));
            Assert.That(scroll.Quantity, Is.EqualTo(1));
            Assert.That(scroll.Magic.Bonus, Is.EqualTo(0));
            Assert.That(scroll.Magic.Charges, Is.EqualTo(0));
            Assert.That(scroll.Magic.SpecialAbilities, Is.Empty);
        }
        public void GenerateCustomSpecificCursedItem()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var itemType = new[] { "item type" };

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

            var attributes = new[] { "attribute 1", "attribute 2" };

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

            var cursedItem = curseGenerator.GenerateSpecificCursedItem(template);

            itemVerifier.AssertMagicalItemFromTemplate(cursedItem, template);
            Assert.That(cursedItem.Name, Is.EqualTo(name));
            Assert.That(cursedItem.IsMagical, Is.True);
            Assert.That(cursedItem.ItemType, Is.EqualTo("item type"));
            Assert.That(cursedItem.Attributes, Is.EquivalentTo(attributes));
            Assert.That(cursedItem.Magic.Curse, Is.EqualTo(CurseConstants.SpecificCursedItem));
            Assert.That(cursedItem.Magic.SpecialAbilities, Is.Empty);
        }
Exemplo n.º 6
0
        public void GenerateCustomWand()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            var wand = wandGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(wand, template);
            Assert.That(wand.Name, Is.EqualTo(name));
            Assert.That(wand.ItemType, Is.EqualTo(ItemTypeConstants.Wand));
            Assert.That(wand.IsMagical, Is.True);
            Assert.That(wand.Attributes, Contains.Item(AttributeConstants.Charged));
            Assert.That(wand.Attributes, Contains.Item(AttributeConstants.OneTimeUse));
            Assert.That(wand.Quantity, Is.EqualTo(1));
            Assert.That(wand.Contents, Is.Empty);
        }
        public void GenerateCustomWondrousItem()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

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

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

            var wondrousItem = wondrousItemGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(wondrousItem, template);
            Assert.That(wondrousItem.Name, Is.EqualTo(name));
            Assert.That(wondrousItem.ItemType, Is.EqualTo(ItemTypeConstants.WondrousItem));
            Assert.That(wondrousItem.IsMagical, Is.True);
            Assert.That(wondrousItem.Attributes, Is.EqualTo(attributes));
        }
Exemplo n.º 8
0
        public void GenerateCustomRing()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

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

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

            var ring = ringGenerator.Generate(template);

            itemVerifier.AssertMagicalItemFromTemplate(ring, template);
            Assert.That(ring.BaseNames.Single(), Is.EqualTo(name));
            Assert.That(ring.Attributes, Is.EquivalentTo(attributes));
            Assert.That(ring.IsMagical, Is.True);
            Assert.That(ring.ItemType, Is.EqualTo(ItemTypeConstants.Ring));
            Assert.That(ring.Quantity, Is.EqualTo(1));
        }
        protected void StressCustomItem()
        {
            var name     = GetRandomName();
            var template = GetRandomTemplate(name);

            var item = magicalItemGenerator.Generate(template);

            AssertItem(item);
            ItemVerifier.AssertMagicalItemFromTemplate(item, template);
        }
        protected void GenerateAndAssertCustomItem()
        {
            var name            = GetRandomName();
            var template        = GetRandomTemplate(name);
            var allowDecoration = Convert.ToBoolean(Random.Next(2));

            var item = magicalItemGenerator.Generate(template, allowDecoration);

            AssertItem(item);
            Assert.That(item.ItemType, Is.EqualTo(itemType));

            if (!allowDecoration)
            {
                ItemVerifier.AssertMagicalItemFromTemplate(item, template);
            }
        }
Exemplo n.º 11
0
        public void GenerateCustomAmmunition()
        {
            var name     = Guid.NewGuid().ToString();
            var template = itemVerifier.CreateRandomTemplate(name);

            template.Magic.SpecialAbilities = Enumerable.Empty <SpecialAbility>();

            var attributes = new[] { "type 1", "type 2", AttributeConstants.Ammunition };

            mockAttributesSelector.Setup(p => p.SelectFrom(TableNameConstants.Collections.Set.AmmunitionAttributes, name)).Returns(attributes);

            var ammunition = ammunitionGenerator.GenerateFrom(template);

            itemVerifier.AssertMagicalItemFromTemplate(ammunition, template);
            Assert.That(ammunition.ItemType, Is.EqualTo(ItemTypeConstants.Weapon));
            Assert.That(ammunition.Quantity, Is.EqualTo(template.Quantity));
            Assert.That(ammunition.Attributes, Is.EqualTo(attributes));
        }