public async void Name_Update_length() { Mock <IProvinceRepository> provinceRepository = new Mock <IProvinceRepository>(); provinceRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Province())); var validator = new ApiProvinceRequestModelValidator(provinceRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiProvinceRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129)); }
public async void Name_Create_null() { Mock <IProvinceRepository> provinceRepository = new Mock <IProvinceRepository>(); provinceRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Province())); var validator = new ApiProvinceRequestModelValidator(provinceRepository.Object); await validator.ValidateCreateAsync(new ApiProvinceRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }
public async void CountryId_Update_Invalid_Reference() { Mock <IProvinceRepository> provinceRepository = new Mock <IProvinceRepository>(); provinceRepository.Setup(x => x.GetCountry(It.IsAny <int>())).Returns(Task.FromResult <Country>(null)); var validator = new ApiProvinceRequestModelValidator(provinceRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiProvinceRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.CountryId, 1); }