示例#1
0
        public async void Category_Update_length()
        {
            Mock <ISpecialOfferRepository> specialOfferRepository = new Mock <ISpecialOfferRepository>();

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

            var validator = new ApiSpecialOfferRequestModelValidator(specialOfferRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiSpecialOfferRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Category, new string('A', 51));
        }
示例#2
0
        public async void Description_Update_null()
        {
            Mock <ISpecialOfferRepository> specialOfferRepository = new Mock <ISpecialOfferRepository>();

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

            var validator = new ApiSpecialOfferRequestModelValidator(specialOfferRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiSpecialOfferRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Description, null as string);
        }
示例#3
0
        public async void Description_Create_length()
        {
            Mock <ISpecialOfferRepository> specialOfferRepository = new Mock <ISpecialOfferRepository>();

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

            var validator = new ApiSpecialOfferRequestModelValidator(specialOfferRepository.Object);
            await validator.ValidateCreateAsync(new ApiSpecialOfferRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Description, new string('A', 256));
        }