public async void UserId_Update_Valid_Reference() { Mock <IStudentRepository> studentRepository = new Mock <IStudentRepository>(); studentRepository.Setup(x => x.UserByUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(new User())); var validator = new ApiStudentServerRequestModelValidator(studentRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiStudentServerRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.UserId, 1); }
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)); }
public async void FirstName_Update_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.ValidateUpdateAsync(default(int), new ApiStudentServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.FirstName, null as string); }