Пример #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 TaggedUserId_Create_Valid_Reference()
        {
            Mock <IDirectTweetRepository> directTweetRepository = new Mock <IDirectTweetRepository>();

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

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

            validator.ShouldNotHaveValidationErrorFor(x => x.TaggedUserId, 1);
        }
Пример #3
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);
        }