public async void LocationId_Create_Valid_Reference() { Mock <ITweetRepository> tweetRepository = new Mock <ITweetRepository>(); tweetRepository.Setup(x => x.LocationByLocationId(It.IsAny <int>())).Returns(Task.FromResult <Location>(new Location())); var validator = new ApiTweetServerRequestModelValidator(tweetRepository.Object); await validator.ValidateCreateAsync(new ApiTweetServerRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.LocationId, 1); }
public async void Content_Create_null() { Mock <ITweetRepository> tweetRepository = new Mock <ITweetRepository>(); tweetRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Tweet())); var validator = new ApiTweetServerRequestModelValidator(tweetRepository.Object); await validator.ValidateCreateAsync(new ApiTweetServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Content, null as string); }
public async void Content_Update_length() { Mock <ITweetRepository> tweetRepository = new Mock <ITweetRepository>(); tweetRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Tweet())); var validator = new ApiTweetServerRequestModelValidator(tweetRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiTweetServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Content, new string('A', 141)); }
public async void UserUserId_Update_Valid_Reference() { Mock <ITweetRepository> tweetRepository = new Mock <ITweetRepository>(); tweetRepository.Setup(x => x.UserByUserUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(new User())); var validator = new ApiTweetServerRequestModelValidator(tweetRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiTweetServerRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.UserUserId, 1); }