public async void Name_Update_length()
        {
            Mock <ICityRepository> cityRepository = new Mock <ICityRepository>();

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

            var validator = new ApiCityRequestModelValidator(cityRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiCityRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
Example #2
0
        public async void Name_Create_null()
        {
            Mock <ICityRepository> cityRepository = new Mock <ICityRepository>();

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

            var validator = new ApiCityRequestModelValidator(cityRepository.Object);
            await validator.ValidateCreateAsync(new ApiCityRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }
        public async void ProvinceId_Update_Invalid_Reference()
        {
            Mock <ICityRepository> cityRepository = new Mock <ICityRepository>();

            cityRepository.Setup(x => x.GetProvince(It.IsAny <int>())).Returns(Task.FromResult <Province>(null));

            var validator = new ApiCityRequestModelValidator(cityRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiCityRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.ProvinceId, 1);
        }