public async void Name_Update_length() { Mock <ICountryRegionRepository> countryRegionRepository = new Mock <ICountryRegionRepository>(); countryRegionRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new CountryRegion())); var validator = new ApiCountryRegionRequestModelValidator(countryRegionRepository.Object); await validator.ValidateUpdateAsync(default(string), new ApiCountryRegionRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51)); }
private async void BeUniqueByName_Create_Not_Exists() { Mock <ICountryRegionRepository> countryRegionRepository = new Mock <ICountryRegionRepository>(); countryRegionRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <CountryRegion>(null)); var validator = new ApiCountryRegionRequestModelValidator(countryRegionRepository.Object); await validator.ValidateCreateAsync(new ApiCountryRegionRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A"); }
public async void Name_Create_null() { Mock <ICountryRegionRepository> countryRegionRepository = new Mock <ICountryRegionRepository>(); countryRegionRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new CountryRegion())); var validator = new ApiCountryRegionRequestModelValidator(countryRegionRepository.Object); await validator.ValidateCreateAsync(new ApiCountryRegionRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }