Exemple #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);
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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);
        }