public async void CountryRegionCode_Create_length() { Mock <IStateProvinceRepository> stateProvinceRepository = new Mock <IStateProvinceRepository>(); stateProvinceRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new StateProvince())); var validator = new ApiStateProvinceRequestModelValidator(stateProvinceRepository.Object); await validator.ValidateCreateAsync(new ApiStateProvinceRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.CountryRegionCode, new string('A', 4)); }
public async void Name_Update_null() { Mock <IStateProvinceRepository> stateProvinceRepository = new Mock <IStateProvinceRepository>(); stateProvinceRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new StateProvince())); var validator = new ApiStateProvinceRequestModelValidator(stateProvinceRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiStateProvinceRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }
private async void BeUniqueByStateProvinceCodeCountryRegionCode_Update_Exists() { Mock <IStateProvinceRepository> stateProvinceRepository = new Mock <IStateProvinceRepository>(); stateProvinceRepository.Setup(x => x.ByStateProvinceCodeCountryRegionCode(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult <StateProvince>(new StateProvince())); var validator = new ApiStateProvinceRequestModelValidator(stateProvinceRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiStateProvinceRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.CountryRegionCode, "A"); }