예제 #1
0
        public async void Content_Update_length()
        {
            Mock <IDirectTweetRepository> directTweetRepository = new Mock <IDirectTweetRepository>();

            directTweetRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new DirectTweet()));

            var validator = new ApiDirectTweetServerRequestModelValidator(directTweetRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiDirectTweetServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Content, new string('A', 141));
        }
예제 #2
0
        public async void Content_Create_null()
        {
            Mock <IDirectTweetRepository> directTweetRepository = new Mock <IDirectTweetRepository>();

            directTweetRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new DirectTweet()));

            var validator = new ApiDirectTweetServerRequestModelValidator(directTweetRepository.Object);
            await validator.ValidateCreateAsync(new ApiDirectTweetServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Content, null as string);
        }
예제 #3
0
        public async void TaggedUserId_Create_Invalid_Reference()
        {
            Mock <IDirectTweetRepository> directTweetRepository = new Mock <IDirectTweetRepository>();

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

            var validator = new ApiDirectTweetServerRequestModelValidator(directTweetRepository.Object);

            await validator.ValidateCreateAsync(new ApiDirectTweetServerRequestModel());

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