public async void Text_Update_null() { Mock <ICommentRepository> commentRepository = new Mock <ICommentRepository>(); commentRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Comment())); var validator = new ApiCommentServerRequestModelValidator(commentRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiCommentServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Text, null as string); }
public async void Text_Create_length() { Mock <ICommentRepository> commentRepository = new Mock <ICommentRepository>(); commentRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Comment())); var validator = new ApiCommentServerRequestModelValidator(commentRepository.Object); await validator.ValidateCreateAsync(new ApiCommentServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Text, new string('A', 701)); }
public async void PostId_Update_Invalid_Reference() { Mock <ICommentRepository> commentRepository = new Mock <ICommentRepository>(); commentRepository.Setup(x => x.PostByPostId(It.IsAny <int>())).Returns(Task.FromResult <Post>(null)); var validator = new ApiCommentServerRequestModelValidator(commentRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiCommentServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.PostId, 1); }
public async void UserId_Create_Invalid_Reference() { Mock <ICommentRepository> commentRepository = new Mock <ICommentRepository>(); commentRepository.Setup(x => x.UserByUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(null)); var validator = new ApiCommentServerRequestModelValidator(commentRepository.Object); await validator.ValidateCreateAsync(new ApiCommentServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.UserId, 1); }