예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        public async void LocationId_Create_Invalid_Reference()
        {
            Mock <ITweetRepository> tweetRepository = new Mock <ITweetRepository>();

            tweetRepository.Setup(x => x.LocationByLocationId(It.IsAny <int>())).Returns(Task.FromResult <Location>(null));

            var validator = new ApiTweetServerRequestModelValidator(tweetRepository.Object);

            await validator.ValidateCreateAsync(new ApiTweetServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.LocationId, 1);
        }
예제 #4
0
        public async void UserUserId_Update_Invalid_Reference()
        {
            Mock <ITweetRepository> tweetRepository = new Mock <ITweetRepository>();

            tweetRepository.Setup(x => x.UserByUserUserId(It.IsAny <int>())).Returns(Task.FromResult <User>(null));

            var validator = new ApiTweetServerRequestModelValidator(tweetRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiTweetServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.UserUserId, 1);
        }