public async void Content_Create_null() { Mock <IQuoteTweetRepository> quoteTweetRepository = new Mock <IQuoteTweetRepository>(); quoteTweetRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new QuoteTweet())); var validator = new ApiQuoteTweetServerRequestModelValidator(quoteTweetRepository.Object); await validator.ValidateCreateAsync(new ApiQuoteTweetServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Content, null as string); }
public async void Content_Update_length() { Mock <IQuoteTweetRepository> quoteTweetRepository = new Mock <IQuoteTweetRepository>(); quoteTweetRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new QuoteTweet())); var validator = new ApiQuoteTweetServerRequestModelValidator(quoteTweetRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiQuoteTweetServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Content, new string('A', 141)); }
public async void RetweeterUserId_Create_Invalid_Reference() { Mock <IQuoteTweetRepository> quoteTweetRepository = new Mock <IQuoteTweetRepository>(); quoteTweetRepository.Setup(x => x.UserByRetweeterUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(null)); var validator = new ApiQuoteTweetServerRequestModelValidator(quoteTweetRepository.Object); await validator.ValidateCreateAsync(new ApiQuoteTweetServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.RetweeterUserId, 1); }
public async void SourceTweetId_Update_Invalid_Reference() { Mock <IQuoteTweetRepository> quoteTweetRepository = new Mock <IQuoteTweetRepository>(); quoteTweetRepository.Setup(x => x.TweetBySourceTweetId(It.IsAny <int>())).Returns(Task.FromResult <Tweet>(null)); var validator = new ApiQuoteTweetServerRequestModelValidator(quoteTweetRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiQuoteTweetServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.SourceTweetId, 1); }