public async Task Add_ShouldAddData() { var rate = new Comment() { Id = "54", Content = "Hello world!", AuthorId = "1", VideoId = "2", }; await commentService.AddAsync(rate); var expected = rate; var actual = data.Last(); Assert.IsNotNull(actual); Assert.AreSame(expected, actual); }
public async Task <IActionResult> Add([FromBody] CommentAddBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetFirstError())); } var comment = Mapper.Map <Comment>(model); comment.AuthorId = User.GetId(); if (comment.AuthorId == null) { return(BadRequest()); } comment = await commentSerivce.AddAsync(comment); var viewModel = Mapper.Map <CommentAddViewModel>(comment); return(Ok(viewModel)); }