コード例 #1
0
 public void Setup()
 {
     mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
     generator    = new AlchemicalItemGenerator(mockTypeAndAmountPercentileSelector.Object);
     result       = new TypeAndAmountPercentileResult();
     itemVerifier = new ItemVerifier();
 }
コード例 #2
0
        public void Setup()
        {
            mockDice = new Mock <Dice>();
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            mockAttributesSelector = new Mock <ICollectionsSelector>();
            generator           = new GoodsGenerator(mockDice.Object, mockTypeAndAmountPercentileSelector.Object, mockAttributesSelector.Object);
            typeAndAmountResult = new TypeAndAmountPercentileResult();
            valueResult         = new TypeAndAmountPercentileResult();

            typeAndAmountResult.Type   = "type";
            typeAndAmountResult.Amount = 2;
            valueResult.Type           = "first value";
            valueResult.Amount         = 9266;
            mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(typeAndAmountResult);

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.GOODTYPEValues, typeAndAmountResult.Type);

            mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(tableName)).Returns(valueResult);

            var descriptions = new[] { "description 1", "description 2" };

            tableName = string.Format(TableNameConstants.Collections.Formattable.GOODTYPEDescriptions, typeAndAmountResult.Type);
            mockAttributesSelector.Setup(p => p.SelectFrom(tableName, It.IsAny <string>())).Returns(descriptions);
            mockDice.Setup(d => d.Roll(1).d(2).AsSum()).Returns(2);
        }
コード例 #3
0
        public void Setup()
        {
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            generator = new CoinGenerator(mockTypeAndAmountPercentileSelector.Object);
            result    = new TypeAndAmountPercentileResult();

            result.Type   = "coin type";
            result.Amount = 9266;
            mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(result);
        }
コード例 #4
0
        public void GetMundaneGearNameAndBonusFromSelector()
        {
            var newResult = new TypeAndAmountPercentileResult();

            newResult.Type   = "new specific gear";
            newResult.Amount = 0;
            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERSpecificITEMTYPEs, power, gearType);

            mockTypeAndAmountPercentileSelector.Setup(s => s.SelectFrom(tableName)).Returns(newResult);

            var gear = specificGearGenerator.GenerateFrom(power, gearType);

            Assert.That(gear.Name, Is.EqualTo("new specific gear"));
            Assert.That(gear.IsMagical, Is.False);
        }
コード例 #5
0
        public void Setup()
        {
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            mockPercentileSelector = new Mock <IPercentileSelector>();
            itemVerifier           = new ItemVerifier();
            potionGenerator        = new PotionGenerator(mockTypeAndAmountPercentileSelector.Object, mockPercentileSelector.Object);

            var result = new TypeAndAmountPercentileResult();

            result.Amount = 9266;
            result.Type   = "potion";
            power         = "power";

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Potion);

            mockTypeAndAmountPercentileSelector.Setup(s => s.SelectFrom(tableName)).Returns(result);
        }
コード例 #6
0
        public void ValueDeterminedByValueResult()
        {
            var secondValueResult = new TypeAndAmountPercentileResult();

            secondValueResult.Type   = "second value";
            secondValueResult.Amount = 90210;

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.GOODTYPEValues, typeAndAmountResult.Type);

            mockTypeAndAmountPercentileSelector.SetupSequence(p => p.SelectFrom(tableName)).Returns(valueResult).Returns(secondValueResult);

            var goods      = generator.GenerateAtLevel(1);
            var firstGood  = goods.First();
            var secondGood = goods.Last();

            Assert.That(firstGood.ValueInGold, Is.EqualTo(9266));
            Assert.That(secondGood.ValueInGold, Is.EqualTo(90210));
        }
コード例 #7
0
        public void MagicalGearDoesNotGetSize()
        {
            mockPercentileSelector.Setup(s => s.SelectFrom(TableNameConstants.Percentiles.Set.MundaneGearSizes))
            .Returns("size");

            var newResult = new TypeAndAmountPercentileResult();

            newResult.Type   = "new specific gear";
            newResult.Amount = 1;
            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERSpecificITEMTYPEs, power, gearType);

            mockTypeAndAmountPercentileSelector.Setup(s => s.SelectFrom(tableName)).Returns(newResult);

            var gear = specificGearGenerator.GenerateFrom(power, gearType);

            Assert.That(gear.Name, Is.EqualTo("new specific gear"));
            Assert.That(gear.IsMagical, Is.True);
            Assert.That(gear.Traits, Is.Not.Contains("size"));
        }
コード例 #8
0
        public void Setup()
        {
            mockTraitsGenerator    = new Mock <IMagicalItemTraitsGenerator>();
            mockAttributesSelector = new Mock <ICollectionsSelector>();
            mockChargesGenerator   = new Mock <IChargesGenerator>();
            mockSpellGenerator     = new Mock <ISpellGenerator>();
            mockPercentileSelector = new Mock <IPercentileSelector>();
            mockDice = new Mock <Dice>();
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            result = new TypeAndAmountPercentileResult();
            wondrousItemGenerator = new WondrousItemGenerator(mockPercentileSelector.Object, mockAttributesSelector.Object, mockChargesGenerator.Object, mockDice.Object, mockSpellGenerator.Object, mockTypeAndAmountPercentileSelector.Object);
            itemVerifier          = new ItemVerifier();

            power         = "power";
            result.Type   = "wondrous item";
            result.Amount = 0;
            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.WondrousItem);

            mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(tableName)).Returns(result);
        }
コード例 #9
0
        public void Setup()
        {
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            mockCollectionsSelector             = new Mock <ICollectionsSelector>();
            mockChargesGenerator = new Mock <IChargesGenerator>();
            result = new TypeAndAmountPercentileResult();
            mockBooleanPercentileSelector = new Mock <IBooleanPercentileSelector>();
            mockSpecialAbilitiesGenerator = new Mock <ISpecialAbilitiesGenerator>();
            rodGenerator = new RodGenerator(mockTypeAndAmountPercentileSelector.Object, mockCollectionsSelector.Object,
                                            mockChargesGenerator.Object, mockBooleanPercentileSelector.Object, mockSpecialAbilitiesGenerator.Object);
            itemVerifier = new ItemVerifier();

            result.Type   = "rod of ability";
            result.Amount = 9266;
            power         = "power";

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Rod);

            mockTypeAndAmountPercentileSelector.Setup(s => s.SelectFrom(tableName)).Returns(result);
        }
コード例 #10
0
        public void Setup()
        {
            mockPercentileSelector              = new Mock <IPercentileSelector>();
            mockCollectionsSelector             = new Mock <ICollectionsSelector>();
            mockSpecialAbilitiesGenerator       = new Mock <ISpecialAbilitiesGenerator>();
            mockMagicItemTraitsGenerator        = new Mock <IMagicalItemTraitsGenerator>();
            mockSpecificGearGenerator           = new Mock <ISpecificGearGenerator>();
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            magicalArmorGenerator = new MagicalArmorGenerator(mockTypeAndAmountPercentileSelector.Object, mockPercentileSelector.Object, mockCollectionsSelector.Object, mockSpecialAbilitiesGenerator.Object, mockSpecificGearGenerator.Object);

            itemVerifier = new ItemVerifier();

            result        = new TypeAndAmountPercentileResult();
            result.Type   = "armor type";
            result.Amount = 9266;
            power         = "power";

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Armor);

            mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(tableName)).Returns(result);
        }
コード例 #11
0
        public void Setup()
        {
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            mockCollectionsSelector             = new Mock <ICollectionsSelector>();
            mockSpecialAbilitiesGenerator       = new Mock <ISpecialAbilitiesGenerator>();
            mockChargesGenerator          = new Mock <IChargesGenerator>();
            mockSpellGenerator            = new Mock <ISpellGenerator>();
            mockPercentileSelector        = new Mock <IPercentileSelector>();
            mockBooleanPercentileSelector = new Mock <IBooleanPercentileSelector>();
            mockDice = new Mock <Dice>();
            specificGearGenerator = new SpecificGearGenerator(mockTypeAndAmountPercentileSelector.Object, mockCollectionsSelector.Object, mockChargesGenerator.Object, mockPercentileSelector.Object, mockSpellGenerator.Object, mockBooleanPercentileSelector.Object, mockDice.Object, mockSpecialAbilitiesGenerator.Object);
            result = new TypeAndAmountPercentileResult();

            power    = "power";
            gearType = "gear type";

            result.Type   = "specific gear";
            result.Amount = 1;
            mockTypeAndAmountPercentileSelector.Setup(s => s.SelectFrom(It.IsAny <string>())).Returns(result);
            itemVerifier = new ItemVerifier();
        }
コード例 #12
0
        public void Setup()
        {
            result = new TypeAndAmountPercentileResult();
            mockMundaneItemGeneratorFactory     = new Mock <IMundaneItemGeneratorRuntimeFactory>();
            mockPercentileSelector              = new Mock <IPercentileSelector>();
            mockMagicalItemGenerator            = new Mock <MagicalItemGenerator>();
            mockMagicalItemGeneratorFactory     = new Mock <IMagicalItemGeneratorRuntimeFactory>();
            mockTypeAndAmountPercentileSelector = new Mock <ITypeAndAmountPercentileSelector>();
            mockMundaneItemGenerator            = new Mock <MundaneItemGenerator>();
            mockRangeAttributesSelector         = new Mock <IRangeAttributesSelector>();

            itemsGenerator = new ItemsGenerator(mockTypeAndAmountPercentileSelector.Object, mockMundaneItemGeneratorFactory.Object, mockPercentileSelector.Object, mockMagicalItemGeneratorFactory.Object, mockRangeAttributesSelector.Object);

            result.Type   = "power";
            result.Amount = 42;
            mockTypeAndAmountPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(result);
            mockPercentileSelector.Setup(p => p.SelectFrom(It.IsAny <string>())).Returns(ItemTypeConstants.WondrousItem);

            var dummyMagicalMock = new Mock <MagicalItemGenerator>();

            dummyMagicalMock.Setup(m => m.GenerateAtPower(It.IsAny <string>())).Returns(() => new Item {
                Name = "magical item"
            });
            mockMagicalItemGeneratorFactory.Setup(f => f.CreateGeneratorOf(It.IsAny <string>())).Returns(dummyMagicalMock.Object);

            var dummyMundaneMock = new Mock <MundaneItemGenerator>();

            dummyMundaneMock.Setup(m => m.Generate()).Returns(() => new Item {
                Name = "mundane item"
            });
            mockMundaneItemGeneratorFactory.Setup(f => f.CreateGeneratorOf(It.IsAny <string>())).Returns(dummyMundaneMock.Object);

            var range = new RangeAttributesResult {
                Maximum = 0, Minimum = 0
            };

            mockRangeAttributesSelector.Setup(s => s.SelectFrom(TableNameConstants.Collections.Set.EpicItems, It.IsAny <string>())).Returns(range);
        }
コード例 #13
0
        public void GetSpecialAbilitiesFromGenerator()
        {
            var abilityResult = new TypeAndAmountPercentileResult();

            abilityResult.Type   = "SpecialAbility";
            abilityResult.Amount = 1;

            var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERITEMTYPEs, power, ItemTypeConstants.Armor);

            mockTypeAndAmountPercentileSelector.SetupSequence(p => p.SelectFrom(tableName)).Returns(abilityResult).Returns(abilityResult).Returns(result);

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

            tableName = string.Format(TableNameConstants.Collections.Formattable.ITEMTYPEAttributes, ItemTypeConstants.Armor);
            mockCollectionsSelector.Setup(p => p.SelectFrom(tableName, It.IsAny <string>())).Returns(attributes);

            var abilities = new[] { new SpecialAbility() };

            mockSpecialAbilitiesGenerator.Setup(p => p.GenerateFor(ItemTypeConstants.Armor, attributes, power, 9266, 2)).Returns(abilities);

            var armor = magicalArmorGenerator.GenerateAtPower(power);

            Assert.That(armor.Magic.SpecialAbilities, Is.EqualTo(abilities));
        }