public void AddCommentTest()
        {
            var comment = new Comment();

            _commentsService.Add(comment);
            _mock.Verify(item => item.Add(comment), Times.Once());
        }
Exemple #2
0
        public ActionResult Create(Comment q)

        {
            Comment p = new Comment();

            p.contenuComment   = q.contenuComment;
            p.date_publication = DateTime.Now;


            Cs.Add(p);
            Cs.Commit();
            return(RedirectToAction("Indexx"));
        }
Exemple #3
0
        public ActionResult Add(CommentCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                Comment commentToAdd = new Comment();
                commentToAdd.Id         = Guid.NewGuid().ToString();
                commentToAdd.AuthorName = model.AuthorName;
                commentToAdd.PostDate   = DateTime.Now;
                commentToAdd.ArticleId  = model.ArticleId;
                commentToAdd.ReviewText = model.Text;
                commentsService.Add(commentToAdd);

                return(RedirectToAction("Details", "Article", new { id = Convert.ToInt32(model.ArticleId) }));
            }
            return(View());
        }
Exemple #4
0
        public void Add_ShouldAddComment_AndReturnTheId()
        {
            Mapper.Initialize(x => x.AddProfile <MapperConfiguration>());
            var repo     = new Mock <IRepository <Comment> >();
            var comments = new List <Comment>().AsQueryable();

            repo.Setup(r => r.All()).Returns(comments);
            var service = new CommentsService(repo.Object);

            //do
            var model = new CreateCommentInputModel
            {
                Content   = "asdjkhaskdjhsjsjsjsjssjjsjssjjssjsjsjsjsjjssjjssjsjjs",
                ProductId = 1,
                UserId    = new Guid().ToString()
            };
            var result = service.Add(model);

            //assert
            result.Should().NotBeNull().And.BeOfType <Task <int> >();
        }
 public async Task <ActionResult> AddComment(Comment comment)
 {
     return(Json(await _service.Add(comment), JsonRequestBehavior.AllowGet));
 }
Exemple #6
0
 public void Post(int feedbackId, [FromBody] CommentDTO value)
 {
     _service.Add(value, User.Identity.GetUserId(), feedbackId);
 }