Example #1
0
        public async void Name_Update_length()
        {
            Mock <IPenRepository> penRepository = new Mock <IPenRepository>();

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

            var validator = new ApiPenRequestModelValidator(penRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiPenRequestModel());

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

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

            var validator = new ApiPenRequestModelValidator(penRepository.Object);
            await validator.ValidateCreateAsync(new ApiPenRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }