public async void UserDisplayName_Update_length() { Mock <IPostHistoryRepository> postHistoryRepository = new Mock <IPostHistoryRepository>(); postHistoryRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new PostHistory())); var validator = new ApiPostHistoryServerRequestModelValidator(postHistoryRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiPostHistoryServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.UserDisplayName, new string('A', 41)); }
public async void RevisionGUID_Create_length() { Mock <IPostHistoryRepository> postHistoryRepository = new Mock <IPostHistoryRepository>(); postHistoryRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new PostHistory())); var validator = new ApiPostHistoryServerRequestModelValidator(postHistoryRepository.Object); await validator.ValidateCreateAsync(new ApiPostHistoryServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.RevisionGUID, new string('A', 37)); }
public async void PostId_Create_Invalid_Reference() { Mock <IPostHistoryRepository> postHistoryRepository = new Mock <IPostHistoryRepository>(); postHistoryRepository.Setup(x => x.PostByPostId(It.IsAny <int>())).Returns(Task.FromResult <Post>(null)); var validator = new ApiPostHistoryServerRequestModelValidator(postHistoryRepository.Object); await validator.ValidateCreateAsync(new ApiPostHistoryServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.PostId, 1); }
public async void UserId_Update_Invalid_Reference() { Mock <IPostHistoryRepository> postHistoryRepository = new Mock <IPostHistoryRepository>(); postHistoryRepository.Setup(x => x.UserByUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(null)); var validator = new ApiPostHistoryServerRequestModelValidator(postHistoryRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiPostHistoryServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.UserId, 1); }