示例#1
0
        public async void Email_Update_length()
        {
            Mock <IStudentRepository> studentRepository = new Mock <IStudentRepository>();

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

            var validator = new ApiStudentServerRequestModelValidator(studentRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiStudentServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Email, new string('A', 129));
        }
示例#2
0
        public async void Email_Create_null()
        {
            Mock <IStudentRepository> studentRepository = new Mock <IStudentRepository>();

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

            var validator = new ApiStudentServerRequestModelValidator(studentRepository.Object);
            await validator.ValidateCreateAsync(new ApiStudentServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Email, null as string);
        }
示例#3
0
        public async void FamilyId_Create_Invalid_Reference()
        {
            Mock <IStudentRepository> studentRepository = new Mock <IStudentRepository>();

            studentRepository.Setup(x => x.FamilyByFamilyId(It.IsAny <int>())).Returns(Task.FromResult <Family>(null));

            var validator = new ApiStudentServerRequestModelValidator(studentRepository.Object);

            await validator.ValidateCreateAsync(new ApiStudentServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.FamilyId, 1);
        }
示例#4
0
        public async void UserId_Update_Invalid_Reference()
        {
            Mock <IStudentRepository> studentRepository = new Mock <IStudentRepository>();

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

            var validator = new ApiStudentServerRequestModelValidator(studentRepository.Object);

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

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