public async void DoesValidatorPreventFromCreatingRecipeWithoutIngredients() { var request = new CreateRecipe { Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-image.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "Sample first step", "Sample second step" } }; var validator = new CreateRecipeValidator(); var result = await validator.ValidateAsync(request); result.IsValid.Should().BeFalse(); }
public async void DoesValidatorPreventFromCreatingRecipeWithTooLongDescription() { var request = new CreateRecipe { Name = "sample-name", Description = string.Concat(Enumerable.Repeat("a", 70000)), PictureUrl = "https://example.com/sample-image.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; var validator = new CreateRecipeValidator(); var result = await validator.ValidateAsync(request); result.IsValid.Should().BeFalse(); }
public async void DoesValidatorPreventFromCreatingRecipeWithInvalidPictureUrl() { var request = new CreateRecipe { Name = "sample-name", Description = "sample-description", PictureUrl = "this-is-not-a-uri", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; var validator = new CreateRecipeValidator(); var result = await validator.ValidateAsync(request); result.IsValid.Should().BeFalse(); }
public async void DoesValidatorAllowCorrectRequest() { var request = new CreateRecipe { Name = "sample-name", Description = "sample-description", PictureUrl = "https://example.com/sample-image.png", Calories = 1234, MealTypes = new[] { MealType.Snack }, Steps = new[] { "1. Sample first step.", "2. Sample second step." }, Ingredients = new[] { "Sample first ingredient", "Sample second ingredient" } }; var validator = new CreateRecipeValidator(); var result = await validator.ValidateAsync(request); result.IsValid.Should().BeTrue(); }