示例#1
0
        public ActionResult AddComment(string addComment, Guid itemId)
        {
            var comment = new CommentDtoModel()
            {
                ItemId = itemId, Description = addComment, UserId = new Guid(User.Identity.GetUserId())
            };

            this.commentService.AddCommnet(comment);
            return(this.PartialView("_CommentsPartial", this.commentService.GetAll(itemId)));
        }
示例#2
0
        public void CallMapperServiceOnce()
        {
            //Arrange
            var mockeGenericRepository = new Mock <IGenericEfRepository <Comment> >();
            var mockedUnitOfWork       = new Mock <IUnitOfWork>();
            var mockedMapper           = new Mock <IMapingService>();
            var commentStub            = new CommentDtoModel();

            mockedMapper.Setup(x => x.Map <Comment>(It.IsAny <CommentDtoModel>())).Verifiable();
            var sut = new CommentService(mockeGenericRepository.Object, mockedUnitOfWork.Object, mockedMapper.Object);

            //Act
            sut.AddCommnet(commentStub);

            //Assert
            mockedMapper.Verify(x => x.Map <Comment>(It.IsAny <CommentDtoModel>()), Times.Once);
        }
示例#3
0
        public void PassSameCommentWithDateToMapper()
        {
            //Arrange
            var mockeGenericRepository = new Mock <IGenericEfRepository <Comment> >();
            var mockedUnitOfWork       = new Mock <IUnitOfWork>();
            var mockedMapper           = new Mock <IMapingService>();
            var commentStub            = new CommentDtoModel();

            mockedMapper.Setup(x => x.Map <Comment>(commentStub)).Verifiable();
            var sut = new CommentService(mockeGenericRepository.Object, mockedUnitOfWork.Object, mockedMapper.Object);

            //Act
            commentStub.Date = DateTime.Now;
            sut.AddCommnet(commentStub);

            //Assert
            mockedMapper.Verify(x => x.Map <Comment>(It.Is <CommentDtoModel>(y => y == commentStub)), Times.Once);
        }
示例#4
0
 public void AddCommnet(CommentDtoModel comment)
 {
     comment.Date = DateTime.Now;
     base.Add(mapper.Map <Comment>(comment));
 }