コード例 #1
0
        public async void Content_Update_length()
        {
            Mock <IReplyRepository> replyRepository = new Mock <IReplyRepository>();

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

            var validator = new ApiReplyServerRequestModelValidator(replyRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiReplyServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Content, new string('A', 141));
        }
コード例 #2
0
        public async void Content_Create_null()
        {
            Mock <IReplyRepository> replyRepository = new Mock <IReplyRepository>();

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

            var validator = new ApiReplyServerRequestModelValidator(replyRepository.Object);
            await validator.ValidateCreateAsync(new ApiReplyServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Content, null as string);
        }
コード例 #3
0
        public async void ReplierUserId_Create_Invalid_Reference()
        {
            Mock <IReplyRepository> replyRepository = new Mock <IReplyRepository>();

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

            var validator = new ApiReplyServerRequestModelValidator(replyRepository.Object);

            await validator.ValidateCreateAsync(new ApiReplyServerRequestModel());

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