Ejemplo n.º 1
0
        protected Base()
        {
            var potionBuilderFactory = new Mock <IPotionBuilderFactory>();

            potionBuilderFactory
            .Setup(x => x.Create())
            .Returns(PotionBuilder.Object);

            PotionBuilder
            .Setup(x => x.AlchemyLevel(It.IsAny <int>()))
            .Returns(PotionBuilder.Object)
            .Verifiable();

            PotionBuilder
            .Setup(x => x.FortifyAlchemyPercent(It.IsAny <decimal>()))
            .Returns(PotionBuilder.Object)
            .Verifiable();

            PotionBuilder
            .Setup(x => x.Ingredient(It.IsAny <IIngredient>()))
            .Returns(PotionBuilder.Object)
            .Verifiable();

            PotionBuilder
            .Setup(x => x.Perk(It.IsAny <IPerk <AlchemySkill> >()))
            .Returns(PotionBuilder.Object)
            .Verifiable();

            Subject = new PotionCreate.CommandHandler(potionBuilderFactory.Object);
        }
Ejemplo n.º 2
0
        protected BaseValid()
        {
            var effect = new Mock <IAlchemyEffect>();

            effect
            .Setup(x => x.Description)
            .Returns(Description);

            var potion = new Mock <IPotion>();

            potion
            .Setup(x => x.Name)
            .Returns(Name);
            potion
            .Setup(x => x.Cost)
            .Returns(Cost);
            potion
            .Setup(x => x.Effects)
            .Returns(new[] { effect.Object });

            var validatedPotionBuilder = new Mock <IValidatedPotionBuilder>();

            validatedPotionBuilder
            .Setup(x => x.Build())
            .Returns(potion.Object);

            PotionBuilder
            .Setup(x => x.Validate())
            .Returns(validatedPotionBuilder.Object);
        }
Ejemplo n.º 3
0
        public void ShouldThrow()
        {
            PotionBuilder
            .Setup(x => x.Validate())
            .Throws(new ValidationException(It.IsAny <string>()));

            Func <Task> action = async() => await Subject.Handle(Request, It.IsAny <CancellationToken>());

            action.Should().Throw <ValidationException>();
        }