Exemplo n.º 1
0
        public async void FirstName_Create_length()
        {
            Mock <IPersonRepository> personRepository = new Mock <IPersonRepository>();

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

            var validator = new ApiPersonRequestModelValidator(personRepository.Object);
            await validator.ValidateCreateAsync(new ApiPersonRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.FirstName, new string('A', 51));
        }
Exemplo n.º 2
0
        public async void LastName_Update_null()
        {
            Mock <IPersonRepository> personRepository = new Mock <IPersonRepository>();

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

            var validator = new ApiPersonRequestModelValidator(personRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiPersonRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.LastName, null as string);
        }
Exemplo n.º 3
0
        public async void Suffix_Update_length()
        {
            Mock <IPersonRepository> personRepository = new Mock <IPersonRepository>();

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

            var validator = new ApiPersonRequestModelValidator(personRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiPersonRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Suffix, new string('A', 11));
        }