コード例 #1
0
        public async void Text_Create_null()
        {
            Mock <ICommentRepository> commentRepository = new Mock <ICommentRepository>();

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

            var validator = new ApiCommentServerRequestModelValidator(commentRepository.Object);
            await validator.ValidateCreateAsync(new ApiCommentServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Text, null as string);
        }
コード例 #2
0
        public async void PostId_Create_Valid_Reference()
        {
            Mock <ICommentRepository> commentRepository = new Mock <ICommentRepository>();

            commentRepository.Setup(x => x.PostByPostId(It.IsAny <int>())).Returns(Task.FromResult <Post>(new Post()));

            var validator = new ApiCommentServerRequestModelValidator(commentRepository.Object);
            await validator.ValidateCreateAsync(new ApiCommentServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.PostId, 1);
        }