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); }
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); }
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>(); }