Ejemplo n.º 1
0
        public async void Email_Update_length()
        {
            Mock <ITeacherRepository> teacherRepository = new Mock <ITeacherRepository>();

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

            var validator = new ApiTeacherServerRequestModelValidator(teacherRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiTeacherServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Email, new string('A', 129));
        }
Ejemplo n.º 2
0
        public async void FirstName_Update_null()
        {
            Mock <ITeacherRepository> teacherRepository = new Mock <ITeacherRepository>();

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

            var validator = new ApiTeacherServerRequestModelValidator(teacherRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiTeacherServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.FirstName, null as string);
        }
Ejemplo n.º 3
0
        public async void UserId_Update_Invalid_Reference()
        {
            Mock <ITeacherRepository> teacherRepository = new Mock <ITeacherRepository>();

            teacherRepository.Setup(x => x.UserByUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(null));

            var validator = new ApiTeacherServerRequestModelValidator(teacherRepository.Object);

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

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