Beispiel #1
0
        public async void CountryId_Update_Valid_Reference()
        {
            Mock <IProvinceRepository> provinceRepository = new Mock <IProvinceRepository>();

            provinceRepository.Setup(x => x.CountryByCountryId(It.IsAny <int>())).Returns(Task.FromResult <Country>(new Country()));

            var validator = new ApiProvinceServerRequestModelValidator(provinceRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiProvinceServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.CountryId, 1);
        }
Beispiel #2
0
        public async void Name_Update_null()
        {
            Mock <IProvinceRepository> provinceRepository = new Mock <IProvinceRepository>();

            provinceRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Province()));

            var validator = new ApiProvinceServerRequestModelValidator(provinceRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiProvinceServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }
Beispiel #3
0
        public async void Name_Create_length()
        {
            Mock <IProvinceRepository> provinceRepository = new Mock <IProvinceRepository>();

            provinceRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Province()));

            var validator = new ApiProvinceServerRequestModelValidator(provinceRepository.Object);
            await validator.ValidateCreateAsync(new ApiProvinceServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }