public async void Name_Update_length() { Mock <IProductCategoryRepository> productCategoryRepository = new Mock <IProductCategoryRepository>(); productCategoryRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new ProductCategory())); var validator = new ApiProductCategoryRequestModelValidator(productCategoryRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiProductCategoryRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51)); }
private async void BeUniqueByName_Update_Not_Exists() { Mock <IProductCategoryRepository> productCategoryRepository = new Mock <IProductCategoryRepository>(); productCategoryRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <ProductCategory>(null)); var validator = new ApiProductCategoryRequestModelValidator(productCategoryRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiProductCategoryRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A"); }